随笔分类 -  LeetCode

摘要:Sort a linked list in O(n log n) time using constant space complexity. Example 1: Example 2: 使用归并排序 阅读全文
posted @ 2019-08-06 21:35 月半榨菜 阅读(121) 评论(0) 推荐(0)
摘要:Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target. E 阅读全文
posted @ 2019-08-06 21:15 月半榨菜 阅读(137) 评论(0) 推荐(0)
摘要:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. For example, two is written as II in Roman numeral, just two one's 阅读全文
posted @ 2019-08-05 15:24 月半榨菜 阅读(105) 评论(0) 推荐(0)
摘要:Given a string containing only three types of characters: '(', ')' and '*', write a function to check whether this string is valid. We define the vali 阅读全文
posted @ 2019-08-05 14:33 月半榨菜 阅读(131) 评论(0) 推荐(0)
摘要:Given a collection of distinct integers, return all possible permutations. Example: 阅读全文
posted @ 2019-07-18 10:24 月半榨菜 阅读(86) 评论(0) 推荐(0)
摘要:Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numb 阅读全文
posted @ 2019-07-18 10:01 月半榨菜 阅读(110) 评论(0) 推荐(0)
摘要:Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the 阅读全文
posted @ 2019-07-18 09:59 月半榨菜 阅读(92) 评论(0) 推荐(0)
摘要:Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two 阅读全文
posted @ 2019-07-17 23:33 月半榨菜 阅读(95) 评论(0) 推荐(0)
摘要:Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. Example 1: Example 2: Note:Your 阅读全文
posted @ 2019-07-17 21:57 月半榨菜 阅读(59) 评论(0) 推荐(0)
摘要:You need to find the largest value in each row of a binary tree. Example: 阅读全文
posted @ 2019-07-17 19:14 月半榨菜 阅读(106) 评论(0) 推荐(0)
摘要:Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Example 2: 阅读全文
posted @ 2019-07-17 18:33 月半榨菜 阅读(76) 评论(0) 推荐(0)
摘要:Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binar 阅读全文
posted @ 2019-07-17 17:56 月半榨菜 阅读(153) 评论(0) 推荐(0)
摘要:Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any 阅读全文
posted @ 2019-07-10 18:24 月半榨菜 阅读(118) 评论(0) 推荐(0)
摘要:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example: 堆+链表 时间复杂度O(nlogk) 阅读全文
posted @ 2019-07-10 17:33 月半榨菜 阅读(108) 评论(0) 推荐(0)
摘要:iven two integer arrays A and B, return the maximum length of an subarray that appears in both arrays. Example 1: Note: 阅读全文
posted @ 2019-07-09 21:38 月半榨菜 阅读(105) 评论(0) 推荐(0)
摘要:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the 阅读全文
posted @ 2019-07-09 21:08 月半榨菜 阅读(64) 评论(0) 推荐(0)
摘要:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the 阅读全文
posted @ 2019-07-09 20:47 月半榨菜 阅读(67) 评论(0) 推荐(0)
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). Y 阅读全文
posted @ 2019-07-09 15:14 月半榨菜 阅读(86) 评论(0) 推荐(0)
摘要:Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into k non-empty subsets whose sums are all 阅读全文
posted @ 2019-07-09 10:26 月半榨菜 阅读(110) 评论(0) 推荐(0)
摘要:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You may not modify the values in the list's nodes, only nodes its 阅读全文
posted @ 2019-07-08 22:08 月半榨菜 阅读(85) 评论(0) 推荐(0)