본문 바로가기
반응형

Study/Algorithm38

[LeetCode] #20. Valid Parentheses (python) 문제 https://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 괄호가 유효한지 확인하는 문제다. 괄호가 같은 종류로 잘 닫혔는지 확인하면 된다. 예시 입출력 Input: s = "()[]{}" Output: true 풀이 내 풀이 class Solution: def isValid(self, s: str) -> bool: stack=[] start=['.. 2022. 2. 24.
[LeetCode] #21. Merge Two Sorted Lists (python) 문제 https://leetcode.com/problems/merge-two-sorted-lists/ Merge Two Sorted Lists - 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 주어진 두 연결 리스트를 하나의 정렬된 연결 리스트로 반환해야 한다. 예시 입출력 Input: list1 = [1,2,4], list2 = [1,3,4] Output: [1,1,2,3,4,4] 풀이 책 풀이 재귀 구조 class Solution: def mergeTwoLi.. 2022. 2. 21.
[LeetCode] #234. Palindrome Linked List (python) 문제 https://leetcode.com/problems/palindrome-linked-list/ Palindrome 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 주어진 연결리스트의 팰린드롬 여부를 확인하는 문제다. 예시 입출력 Input: head = [1,2,2,1] Output: true 풀이 내 풀이 class Solution: def isPalindrome(self, head: Optional[ListNode]) -> bo.. 2022. 2. 21.
[LeetCode] #1. Two Sum (python) 문제 https://leetcode.com/problems/two-sum/ Two Sum - 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 주어진 숫자 리스트에서 더하면 target 값이 되는 두 수의 인덱스 값을 리스트로 반환해야 하는 문제다. 예시 입출력 Input: nums = [2,7,11,15], target = 9 Output: [0,1] 풀이 내 풀이 class Solution: def twoSum(self, nums: List[int], targe.. 2022. 2. 21.
반응형