분류 전체보기
-
2021-02-04] Longest Harmonious SubsequenceIT/자기계발 ( Leetcode ) 2021. 2. 4. 23:37
오늘의 문제: leetcode.com/explore/featured/card/february-leetcoding-challenge-2021/584/week-1-february-1st-february-7th/3628/ harminious subsequence를 정의하자면, 특정 값과 인접한 수( if N=2 / 1,3 )를 포함한 부분집합을 의미하고 return 값으로는 이 부분집합들의 최대로 긴 값을 리턴하는 것이다. 예시 1번을 천천히 뜯어보자. nums=[1,3,2,2,5,2,3,7] 의 조화로운 부분집합은 1) [1,2,2,2] 길이 = 4 2) [3,2,2,2,3] 길이 = 5 두 개 뿐이다. ( 5,7 은 인접한 수가 없다. ) 그래서 1번 답은 5이다. 예시 2번은 [1,2],[2,3],[3,..
-
2021-02-03] Linked List CycleIT/자기계발 ( Leetcode ) 2021. 2. 3. 22:53
오늘의 문제: leetcode.com/explore/featured/card/february-leetcoding-challenge-2021/584/week-1-february-1st-february-7th/3627/ Explore - LeetCode LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore. leetcode.com 제목에서처럼 Linked List안에 Cycle이 있으면 True, 없으면 False 값을..
-
2021-02-02] Trim a Binary Search TreeIT/자기계발 ( Leetcode ) 2021. 2. 3. 22:45
오늘의 문제: leetcode.com/problems/trim-a-binary-search-tree/ Trim a Binary Search Tree - 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 이번 문제는 BST 에서 필요한 부분을 나눠주는 부분이다. 아래 예제를 보자 입력값으로 주어지는 root, low,high로 root Node안에서 low, high 사이의 값만 남기고 나머지는 제거하는 문제이다. low, high 경계 밖의 값을 제거하면서, BST..
-
2021-02-01] Number of 1 BitsIT/자기계발 ( Leetcode ) 2021. 2. 1. 22:53
오늘의 문제:leetcode.com/explore/challenge/card/february-leetcoding-challenge-2021/584/week-1-february-1st-february-7th/3625/ 지난 한 달 동안 그래도 열심히 알고리즘 문제를 풀며, 블로그를 작성중이다. ( 스스로에게 칭찬한다.. ) 앞으로도 꾸준히 블로그도 쓰고, 문제도 풀며 발전하는 내가 되면 좋겠다. 2월 첫번째 문제라 그런지, 문제의 난이도는 Easy이다. 1월 첼린지를 포기했던 사람들도 다시 도전해보며 자신감을 가질 수 있는 난이도를 선택한게 아닐까ㅋㅋ 이번 문제도 예시를 보며 이해해보자. 주어지는 32bit로 2진수로 표현된 값에서 1이 있는 값을 출력해주는 내용이다. 예시로만 보면, 매우 간단해 보인다...
-
2021-01-31] Next PermutationSolutionIT/자기계발 ( Leetcode ) 2021. 2. 1. 00:06
오늘의 문제: leetcode.com/explore/challenge/card/january-leetcoding-challenge-2021/583/week-5-january-29th-january-31st/3623/ 이번 문제의 난이도는 Medium 이지만, 순열에 대해서 잘 몰랐던 나는 이해하는데 어려움이 있었다. 문제 예시를 보며 이해한 내용을 공유한다. 숫자로 된 List nums 값이 주어지만, 그 다음번에 해당하는 순열을 구하면 된다. 예시 1번과 2번처럼 1,2,3이라는 원소로 만들 수 있는 순열은 총 6개이다. [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] 2번에서 다음 번 순열이 없을 경우, 처음거로 돌아온다. 원소 3개로는 너무 적으니 5개..
-
2021-01-30] Swapping Nodes in a Linked ListIT/자기계발 ( Leetcode ) 2021. 1. 31. 16:23
오늘의 문제:leetcode.com/problems/swapping-nodes-in-a-linked-list/ Swapping Nodes in a Linked List - 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 Daily Challenge는 어려워서.. 하고 Medium 문제중 하나를 선택하여 풀어보았다. 해당 예시를 보며 생각해보자. 입력값으론 Linked list 와 int가 주어지는데, ListNode의 앞에서 k 번째 값과 끝에서 k 번째 값을 스..
-
2021-01-29] Vertical Order Traversal of a Binary TreeIT/자기계발 ( Leetcode ) 2021. 1. 29. 23:33
오늘의 문제: leetcode.com/explore/challenge/card/january-leetcoding-challenge-2021/583/week-5-january-29th-january-31st/3621/ Explore - LeetCode LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore. leetcode.com 후.. Hard하다 Hard해.. ㅋㅋㅋㅋ 이번문제는 분류가 Hard여서 그런가 고려해야할..
-
2021-01-28] Smallest String With A Given Numeric ValueIT/자기계발 ( Leetcode ) 2021. 1. 29. 00:10
오늘의 문제: leetcode.com/explore/challenge/card/january-leetcoding-challenge-2021/582/week-4-january-22nd-january-28th/3619/ 주어지는 n,k로 문자열을 만들어 주는 문제이다. 문자열의 법칙은 아래 예시를 보며 이해해보자. 예시 1번을 보면 n은 3 , k는 27이다. n은 문자열의 길이를 말하는 것이고, k는 이로 만들수 있는 사전정렬(알파벳순)의 가장 앞 순서의 문자열을 말하는 것이다. 문제에서 처럼 a=1,b=2,c=3 ..... z=26의 숫자를 갖는다. 총 알파벳이 26자이기 때문이다. k= 27일때 3개의 수로 표현한다면, 1+1+25가 될 수 있다. 물론 1+2+24 등도 되지만, 앞에 제약조건으로 사전..