TIL

    [LeetCode] Lemonade Change (Python)

    이전에 풀어본 문제를 다른 언어로 풀어보기로 했다. 고랭에도 관심이 갔지만 일단 좀 더 대중화되어 있는 파이썬으로 도전! Lemonade Change - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com class Solution: def lemonadeChange(self, bills: List[int]) -> bool: ch5=0 ch10=0 for bill in bills: if bill == 5: ch5+=1 elif bill == 10: if ch5 > 0..

    [백준] 베스트셀러 Best Seller

    3월 26일 문제였다. 1302번: 베스트셀러 첫째 줄에 오늘 하루 동안 팔린 책의 개수 N이 주어진다. 이 값은 1,000보다 작거나 같은 자연수이다. 둘째부터 N개의 줄에 책의 제목이 입력으로 들어온다. 책의 제목의 길이는 50보다 작거나 같고 www.acmicpc.net 답안 코드. import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.TreeMap; import java.util.Map.Entry; public class cote0326_Be..

    [프로그래머스] 오픈채팅방

    오늘의 문제. 카카오 2019 블라인드 채용 문제로 나온 문제인가보다. 30분엔 어림도 없지.. 60분 꽉 채워서 풀었다. 어쨌든 풀어서 기분은 좋음. 코딩테스트 연습 - 오픈채팅방 오픈채팅방 카카오톡 오픈채팅방에서는 친구가 아닌 사람들과 대화를 할 수 있는데, 본래 닉네임이 아닌 가상의 닉네임을 사용하여 채팅방에 들어갈 수 있다. 신입사원인 김크루는 카카오톡 오 programmers.co.kr import java.util.HashMap; import java.util.Map; public class cote0324_chatroom { /* ~ 의식의 흐름 ~ 유저아이디에 따라서 마지막 닉네임을 해당 닉네임으로 저장 Enter, Leave는 각각 들어왔습니다, 나갔습니다. Change는 로그만 남고 리..

    [프로그래머스] 카펫

    오느릐 문제. 내가 골랐다. 이런 식으로 그림이랑 같이 나오는 문제가 코테에 자주 나오는 것 같아서 골라보았다. 접근방법을 생각하기가 조금 어려웠지만 수식만 조금씩 수정해나가니까 계산이 맞아서 생각보다 빨리 풀렸다. 솔직히 처음 10분은 아 오늘도 못풀겠군,, 이라고 생각했음. 코딩테스트 연습 - 카펫 Leo는 카펫을 사러 갔다가 아래 그림과 같이 중앙에는 노란색으로 칠해져 있고 테두리 1줄은 갈색으로 칠해져 있는 격자 모양 카펫을 봤습니다. Leo는 집으로 돌아와서 아까 본 카펫의 노란색과 programmers.co.kr import java.util.ArrayList; import java.util.List; class cote0323_carpet{ /* ~ 의식의 흐름 ~ 브라운+옐로의 합은 가로세..

    [프로그래머스] 주식가격

    오늘의 문제. 프로그래머스 플랫폼 문제다. 오랜만에 한글 보니까 넘 반갑.. 코딩테스트 연습 - 주식가격 초 단위로 기록된 주식가격이 담긴 배열 prices가 매개변수로 주어질 때, 가격이 떨어지지 않은 기간은 몇 초인지를 return 하도록 solution 함수를 완성하세요. 제한사항 prices의 각 가격은 1 이상 10,00 programmers.co.kr 초 단위로 기록된 주식가격이 담긴 배열 prices가 매개변수로 주어질 때, 가격이 떨어지지 않은 기간은 몇 초인지를 return 하도록 solution 함수를 완성하세요. 제한사항 1. prices의 각 가격은 1 이상 10,000 이하인 자연수입니다. 2. prices의 길이는 2 이상 100,000 이하입니다. 의식의 흐름은 맞았는데 코드로..

    [LeetCode] Majority Element

    오늘의 문제. leetcode.com/problems/majority-element/ Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. 크기가 n인 정수 배열 nums가 주어진다. 가장 많은 요소를 리턴하시오. 가장 많은 요소는 n/2 이상 나타나는 요소이다. 배열에서 항상 존재한다고 가정할 수 있다. Constraints: 1. n == nums.length 2. 1

    [LeetCode] Lemonade Change

    오늘의 문제. 문제 이름이 맘에 든다. 레모네이드 거스름돈! At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You must provide the correct change to each customer, so that the net transaction is that the customer pays $5. Note that yo..

    [LeetCode] Two Sum

    오늘의 문제. Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.You may assume that each input would have exactly one solution, and you may not use the same element twice.You can return the answer in any order. 정수 배열인 nums와 정수 target이 주어진다. 더하면 target값이 되는 두 숫자의 인덱스를 리턴하라.한가지 배열 요소를 두 번 이상 사용하지 않는다. 솔루션은 하나뿐이라고 가정할 수 있다. 답안을 어떤 순서대..

    [LeetCode] Top K Frequent Elements

    오늘의 문제 문제를 읽어보며 예상하긴 했지만 구글링 없이 현재의 내 능력으론 절대 풀 수 없는 문제였다. Top K Frequent Elements - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 시도해 본 흔적. import java.util.HashMap; import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; /*Given a non-empty array of integers..

    [LeetCode] Roman to Integer

    오느릐 문제. 로마 숫자를 정수형태로 바꿔보기. leetcode.com/problems/roman-to-integer/ Roman to Integer - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 아래는 처음에 푼 방식. 제대로 작동하기는 했으나 속도도 느리고.. 음.. public class cote0312_13_RomanToInteger { public int romanToInt(String s) { //s의 길이를 알아야겠징 int[] iArr=new ..