목록분류 전체보기 (31)
코딩 공부

[LeetCode] [Easy] 1446. Consecutive Characters leetcode.com/problems/consecutive-characters/ Consecutive Characters - 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 가장 많이 연속된 캐릭터 찾기 for loop을 돌면서 전 캐릭터와 같은지 비교하고 같으면 max 값을 업데이트해주면 끝 (다르면 초기화) 비교적 쉬웠던 문제였어요 ㅎㅎ

[LeetCode] [Easy] 1480. Running Sum of 1d Array leetcode.com/problems/running-sum-of-1d-array/ Running Sum of 1d Array - 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 RunningSum 구하기 처음부터 현재 인덱스까지 합이 Running Sum 이라네요. running sum[i] = nums[0]+ nums[1] + ... + nums[i] for loop을 돌면서..

[LeetCode] [Easy] 171. Excel Sheet Column Title leetcode.com/problems/excel-sheet-column-title/ Excel Sheet Column Title - 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 엑셀 Column Title 계산하기 첫번째는 A, 두번째는 B, ... ,26번째는 Z, 27번째는 AA 이런 방식으로 주어진 수(n번째)에 맞는 문자열을 찾아봅시다. 알파벳이 26개가 있으니 26..

[LeetCode] [Easy] 136. Single Number leetcode.com/problems/single-number/ Single Number - 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 반복되지 않는 숫자 찾기 배열안에 모든 숫자는 2번씩 나오는데 한 숫자만 한번 나옵니다. 그 숫자를 찾는게 문제에요. Hash Map을 사용해서 를 저장하고 빈도수가 1인걸 찾아줬어요. 별로 만족스럽지 않은 결과네요 ㅠㅠ XOR 을 이용해서 푸는 방법이 있더..

[LeetCode] [Easy] 412. Fizz Buzz leetcode.com/problems/fizz-buzz/ Fizz Buzz - 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 Fizz Buzz 3의 배수일때는 Fizz 5의 배수일때는 Buzz 15의 배수일때는 FizzBuzz를 나머지는 숫자를 넣는 리스트 만들기 여태 풀었던 문제중 가장 쉬웠던 것 같아요 ㅎㅎㅎ

[LeetCode] [Easy] 1394. Find Lucky Integer in an Array leetcode.com/problems/find-lucky-integer-in-an-array/ Find Lucky Integer in an Array - 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 럭키넘버 찾기 어떤 숫자가 배열안에서 나온 빈도수가 배열안에 있으면 럭키넘버! 여러개가 있다면 최대값을 리턴하면 되요. 1. Hash Map을 사용해서 키 값은 배열..

[LeetCode] [Easy] 1470. Shuffle the Array leetcode.com/problems/shuffle-the-array/ Shuffle the Array - 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 배열 셔플하기 [x1,x2,...,xn,y1,y2,...,yn] 형태의 배열이 있을때 [x1,y1,x2,y2,...,xn,yn] 형태의 배열로 바꾸기 (배열 길이 = 2n) 예) [2,5,1,3,4,7] => [2,3,5,4,1,7] ..

[LeetCode] [Easy] 283. Move Zeroes leetcode.com/problems/move-zeroes/ Move Zeroes - 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 배열 안에 있는 0 뒤로 보내기 제가 설명을 잘 못해서 코드로 보는게 편할지도 모르겠네요 ㅋㅋㅋ 앞쪽부터 0을 무시하면서 나머지 숫자로 덮어씌우고 나중에 0으로 채워줍니다. 0이 나올경우를 대비해서 포인터가 필요합니다. 예) [1, 0, 3, ...] 포인터는 inde..

[LeetCode] [Easy] 415. Add Strings leetcode.com/problems/add-strings/ Add Strings - 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 숫자로만 이루어진 2개의 문자열의 합을 문자열로 리턴하기 쉽게 생각하면 문자열 숫자를 int, double 같은 숫자로 바꾸고 두 수를 더해서 리턴하면 될것 같지만 그 방법은 금지 그래서 제가 생각한 방법은 char 배열로 나눠서 각자리 수를 더하기 1. toCharA..

[LeetCode] [Easy] 20. Valid Parentheses leetcode.com/problems/valid-parentheses/ Valid Parentheses - 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 주어진 문자열이 유효한 괄호들인지 확인하기 이런 경우에는 스텍을 사용하면 편한것 같습니다. 1. 문자열 처음이 닫히는 괄호로 시작한다면 바로 손절 2. 스텍을 만들기 3. 열리는 괄호면 스텍에 넣어주기 4. 닫히는 괄호면 스텍 가장 위에 ..