- Today
- Total
목록스터디/코테 (223)
작심삼일
문제 링크: https://leetcode.com/problems/sort-list/ 문제 Given the head of a linked list, return the list after sorting it in ascending order. 조건 The number of nodes in the list is in the range [0, 5 * $10^4$]. $-10^5$ Optional[ListNode]: if not head: return head array = [] while head.next: array.append(head.val) head = head.next array.append(head.val) array = sorted(array) ans = ListNode(array[0]) an..
문제 링크: https://leetcode.com/problems/clone-graph/ 문제 Given a reference of a node in a connected undirected graph. Return a deep copy (clone) of the graph. Each node in the graph contains a value (int) and a list (List[Node]) of its neighbors. class Node { public int val; public List neighbors; } 조건 The number of nodes in the graph is in the range [0, 100]. 1
문제 링크: https://leetcode.com/problems/excel-sheet-column-number/ 문제 Given a string columnTitle that represents the column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... 조건 1
문제 링크: https://leetcode.com/problems/majority-element/ 문제 Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. 조건 n == nums.length 1
문제 링크: https://leetcode.com/problems/remove-k-digits/ 문제 Given string num representing a non-negative integer num, and an integer k, return the smallest possible integer after removing k digits from num. 조건 1 0 and k > 0 and digit 0: ans.pop() k -= 1 ans = ''.join(ans).lstrip('0') if ans == '': return '0' return ans
문제 링크: https://leetcode.com/problems/combination-sum/ 문제 Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order. The same number may be chosen from candidates an unlimited number of times. Two combinations are unique if the frequency of ..
문제 링크: https://leetcode.com/problems/swap-nodes-in-pairs/ 문제 Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.) 조건 The number of nodes in the list is in the range [0, 100]. 0
문제 링크: https://leetcode.com/problems/single-number/ 문제 Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space. 조건 1