IT/자기계발 ( Leetcode )
-
2021-01-13] Add Two NumbersIT/자기계발 ( Leetcode ) 2021. 1. 13. 12:41
오늘의 문제: leetcode.com/explore/challenge/card/january-leetcoding-challenge-2021/580/week-2-january-8th-january-14th/3601/ 확실히 주말에 힘든 문제인것 같은 느낌이다! 다행이 오늘 문제도 풀 수 있었다~ 자 예시를 보며 문제를 이해하자. 입력 값으로 ListNode 2개를 준다. 그 값이 더해져 값을 넘겨주는 것. 설명을 보면 결국 ListNode의 합산된 값의 새로운 List를 달라는 말이다. 문제풀이 1차) list의 시작부터 l1의 첫번재값*10의0승 = 첫째자리의 값 을 이용하여, list 마다 가진 값을 만들고, 둘을 합해 역순으로 list를 만들어 보는 방법을 선택했다. # Definition for s..
-
2021-01-12] Merge Sorted ArrayIT/자기계발 ( Leetcode ) 2021. 1. 12. 00:00
오늘의 문제: leetcode.com/explore/challenge/card/january-leetcoding-challenge-2021/580/week-2-january-8th-january-14th/3600/ 간만쓰 쉬운 문제였던것 같다..ㅎㅎ 주말엔 시간이 많을테니 어려운 문제를 주는지 토/일은 문제가 힘들어서 고통이었다ㅜ 이 문제는 array관련 문제로 예시를 보며 이해해보자. nums1의 길이는 두 list를 합칠만큼의 공간이 주어지고, 실제 값이 있는 길이는 m으로 주어진다. 이를 sort하여 값을 주면 완성. 주의할 점은 return값이 없고 주어진 nums1 list에 sort된 값을 넣어서 반환하면 된다. 문제풀이) class Solution(object): def merge(self,..
-
2021-01-11] Valid SudokuIT/자기계발 ( Leetcode ) 2021. 1. 11. 18:52
오늘의 문제: leetcode.com/problems/valid-sudoku/ Valid Sudoku - 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 sudoku에 대해서 이해하고 있다면, 문제는 쉬울 것이다, 총 9X9 행렬이 주어지고, sudoku로써 맞는지 검증하는 문제이다. 예시의 그림을 보며 이해해 보자. sudoku의 조건은 결국 아래 2가지로 정리될 것 같다. 1) 각 n행,n열 각각 모든 숫자들이 1-9 까지 중복되지 않고 들어간다. 2) 각 s..
-
2021-01-10] Create Sorted Array through InstructionsIT/자기계발 ( Leetcode ) 2021. 1. 11. 00:14
오늘의 문제: leetcode.com/explore/challenge/card/january-leetcoding-challenge-2021/580/week-2-january-8th-january-14th/3599/ 이번 문제는 이해가 조금 어려웠다.. ( 아직 필자는 답을 만들진 못했다.) 예시를 보며 문제를 이해해보자. 입력값으로 배열을 주어지면, 정렬을 하면서 생긴, cost 값에 대해서 최소값에 대해 합을 구하는 문제이다. cost라는 것의 비교값으로 주어지는 것들은 정렬을 하면서 정렬값이 되었을때, 왼쪽의 원소의 개수와 오른쪽의 원소의 개수이다. 1번 예시를 보며 이해해보자. 1) 첫번째 값 1을 넣으면 값이 하나이기에 양옆의 값은 0 , 0 min은 0이고, 2) 두번째 값 5를 넣으면 5는 1..
-
2021-01-09] Check If Two String Arrays are Equivalent & Duplicate ZerosIT/자기계발 ( Leetcode ) 2021. 1. 9. 00:00
오늘의 문제: leetcode.com/problems/check-if-two-string-arrays-are-equivalent/ Check If Two String Arrays are Equivalent - 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 leetcode.com/problems/duplicate-zeros/ Duplicate Zeros - LeetCode Level up your coding skills and quickly land a job...
-
2021-01-08] Longest Substring Without Repeating CharactersIT/자기계발 ( Leetcode ) 2021. 1. 8. 00:00
오늘의 문제: leetcode.com/explore/challenge/card/january-leetcoding-challenge-2021/579/week-1-january-1st-january-7th/3595/ 이번 문제는 한줄이지만, 한마디론 표현이 잘안되니 예시를 보며 이야기해보자. input값으로 문자열이 주어지고, 이 안에서 중복되는 값이 없는 substring의 최대 길이를 구하는 것이 문제이다. 예시 1처럼 "abcabcbb" 라면 "abc","bca","cab"가 가장 긴 substring이고 최대 길이는 3이다 문제풀이 ) class Solution(object): def lengthOfLongestSubstring(self, s): maxval=1 if s == "": return 0 ..
-
2021-01-07] Kth Missing Positive NumberIT/자기계발 ( Leetcode ) 2021. 1. 7. 00:00
오늘의 문제: leetcode.com/problems/kth-missing-positive-number/ Kth Missing Positive 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 이번 문제도 이해는 쉬웠던 것 같다! 입력값으로 주는 arr에 값을 제외한 [1~1000] 이하의 List의 입력값 k번째의 값을 구하는 것이다! 예시를 보며 같이 이해해보자 입력값으로 [2,3,4,7,11] 이 주어졌으니 해당 내용을 제외한 [1~1000]의..
-
2021-01-06] Remove Duplicates from Sorted List IIIT/자기계발 ( Leetcode ) 2021. 1. 6. 23:45
하루하루.. 꾸준히 쓴다는 것은 정말 어렵다.. 문제 푸는 것도 그렇고, 그것을 정리하여 블로그로 남기는 것까지 할라니 쉽지가 않다.. 그래도 5일만에 무너질수없으니 오늘도 문제를 풀어봅시다. 오늘의 문제: leetcode.com/problems/remove-duplicates-from-sorted-list-ii/ Remove Duplicates from Sorted List II - 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 문제 자체는 쉽게 이해하였다! ..