- Today
- Total
목록leetcode (186)
작심삼일
문제 링크: https://leetcode.com/problems/linked-list-cycle/ 문제 Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected to. Note that pos is..
문제 링크: https://leetcode.com/problems/merge-two-sorted-lists/ 문제 You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. 조건 The number of nodes in both lists is in the range [0, 50]. -100

문제 링크: https://leetcode.com/problems/champagne-tower/ 문제 We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the $100^{th}$ row. Each glass holds one cup of champagne. Then, some champagne is poured into the first glass at the top. When the topmost glass is full, any excess liquid poured will fall equally to the glass immediately to the l..
문제 링크: https://leetcode.com/problems/arithmetic-slices/ 문제 An integer array is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same. For example, [1,3,5,7,9], [7,7,7,7], and [3,-1,-5,-9] are arithmetic sequences. Given an integer array nums, return the number of arithmetic subarrays of nums. A subarray is a contiguous ..
문제 링크: https://leetcode.com/problems/is-subsequence/ 문제 Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" ..
문제 링크: https://leetcode.com/problems/compare-version-numbers/ 문제 Given two version numbers, version1 and version2, compare them. Version numbers consist of one or more revisions joined by a dot '.'. Each revision consists of digits and may contain leading zeros. Every revision contains at least one character. Revisions are 0-indexed from left to right, with the leftmost revision being revision 0..
문제 링크: 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