
LeetCode
buki26
这个作者很懒,什么都没留下…
展开
-
树的最小深度
给定一棵二叉树,返回树的最小深度。最小深度是从根节点到叶子结点的最短路径。原创 2017-06-28 16:30:50 · 456 阅读 · 0 评论 -
rotate-list
Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given1->2->3->4->5->NULLand k =2, return4->5->1->2->3->NULL.原创 2017-07-04 15:27:56 · 185 阅读 · 0 评论 -
merge-two-sorted-lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.原创 2017-07-04 16:58:25 · 192 阅读 · 0 评论 -
remove-duplicates-from-sorted-list
Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given1->1->2, return1->2. Given1->1->2->3->3, return1->2->3.原创 2017-07-04 19:47:16 · 189 阅读 · 0 评论 -
partition-list
给定一个链表和一个值,使小于这个值的节点在前,大于或等于的在后。 Given1->4->3->2->5->2and x = 3, return1->2->2->4->3->5.原创 2017-07-06 09:56:21 · 183 阅读 · 0 评论 -
remove-duplicates-from-sorted-list-ii
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Given1->2->3->3->4->4->5, return1->2->5. Given1->1->1->2-原创 2017-07-06 11:01:02 · 267 阅读 · 0 评论 -
add-two-numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linke原创 2017-07-07 10:38:00 · 176 阅读 · 0 评论 -
swap-nodes-in-pairs
Given a linked list, swap every two adjacent nodes and return its head. For example, Given1->2->3->4, you should return the list as2->1->4->3.原创 2017-07-07 11:13:38 · 200 阅读 · 0 评论 -
remove-nth-node-from-end-of-list
Given a linked list, remove the n th node from the end of list and return its head.原创 2017-07-07 15:00:18 · 307 阅读 · 0 评论 -
valid-palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, “A man, a plan, a canal: Panama”is a palindrome. “race a car”is not a palin原创 2017-07-08 11:19:46 · 210 阅读 · 0 评论 -
sum-root-to-leaf-numbers
Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number. An example is the root-to-leaf path1->2->3which represents the number123. Find the total sum of all原创 2017-07-24 17:05:36 · 440 阅读 · 0 评论 -
populating-next-right-pointers-in-each-node
连接左右子节点原创 2017-07-24 18:47:21 · 241 阅读 · 0 评论 -
path-sum i & ii
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: Given the below binary tree andsum =原创 2017-07-25 16:13:49 · 293 阅读 · 0 评论 -
平衡二叉树
给一颗二叉树,判断是否是平衡二叉树,(任意节点的左右子节点深度相差不超过1)思路:递归,这个题需要记住代码:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(原创 2017-07-26 11:18:37 · 220 阅读 · 0 评论 -
convert-sorted-list-to-binary-search-tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.原创 2017-07-03 19:14:49 · 322 阅读 · 0 评论 -
linked-list-cycle-ii
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can you solve it without using extra space?原创 2017-07-03 16:11:21 · 286 阅读 · 0 评论 -
copy-list-with-random-pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list.原创 2017-07-02 10:55:06 · 248 阅读 · 0 评论 -
evaluate-reverse-polish-notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation.原创 2017-06-29 10:15:02 · 213 阅读 · 0 评论 -
max-points-on-a-line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.原创 2017-06-29 21:38:01 · 402 阅读 · 0 评论 -
sort-list
Sort a linked list in O(n log n) time using constant space complexity.原创 2017-06-29 21:40:15 · 198 阅读 · 0 评论 -
插入排序链表
用插入排序实现对链表的排序原创 2017-06-29 21:42:04 · 259 阅读 · 0 评论 -
二叉树的前、中、后序遍历
二叉树的前中后序遍历原创 2017-06-30 19:18:17 · 247 阅读 · 0 评论 -
jump-game
Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position.原创 2017-07-10 17:54:44 · 214 阅读 · 0 评论 -
最大子数组问题
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.原创 2017-07-11 15:32:37 · 236 阅读 · 0 评论 -
翻转链表
单链表原地翻转的问题原创 2017-07-01 20:45:24 · 307 阅读 · 0 评论 -
翻转部分链表
单链表翻转的第二个版本。原创 2017-07-01 21:27:38 · 265 阅读 · 0 评论 -
Minimum Window Substring
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = “ADOBECODEBANC”T = “ABC”Minimum window is “BANC”.Note:If ther原创 2017-07-11 17:34:47 · 239 阅读 · 0 评论 -
pascals-triangle
Given numRows, generate the first numRows of Pascal’s triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]原创 2017-07-12 11:14:29 · 277 阅读 · 0 评论 -
pascals-triangle-ii
Given an index k, return the k th row of the Pascal’s triangle. For example, given k = 3, Return[1,3,3,1].原创 2017-07-12 14:54:13 · 373 阅读 · 0 评论 -
linked-list-cycle
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space?原创 2017-07-03 15:18:02 · 177 阅读 · 0 评论 -
minimum-path-sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at any原创 2017-09-08 10:20:35 · 289 阅读 · 0 评论