본문 바로가기

전체 글

(18)
[leetcode] 35. Search Insert Position _ python3 35. Search Insert Position Search Insert Position - 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 풀이 코드 정렬된 숫자가 담겨있는 리스트 List와 찾고자 하는 숫자 target이 주어진다. 이때 target이 발견되면 해당 위치의 인덱스를 반환하고, 발견되지 않으면 List에 target이 들어가서 정렬된 경우 target의 인덱스를 반환해 주는 문제이다. 변수 l 에 0을 변수 h에 가장 큰 인덱스 값을 저장한다. ..
[leetcode] 739. Daily Temperatures _ python3 739. Daily Temperatures Daily Temperatures - 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 풀이 코드 일일 온도가 담겨있는 리스트를 줬을 때, 더 따뜻한 날씨가 되려면 며칠 더 기다려야 하는지 리스트로 리턴해야 하는 문제이다. stack이라는 이름의 리스트에 현재 위치 인덱스를 계속 저장해 준다. 현재 온도가 stack의 가장 마지막에 존재하는 인덱스의 온도 보다 높으면 stack에서 인덱스를 꺼내고 현재 인덱스와 꺼낸 인덱스..
[leetcode] 203. Remove Linked List Elements _ python3 203. Remove Linked List Elements Remove Linked List 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 풀이 코드 리스트의 노드를 탐색하면서 val에 해당하는 값이 나오면 해당 노드를 제거하면 된다. # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # sel..