随笔分类 -  Leetcode

上一页 1 ··· 7 8 9 10 11 12 下一页
108. Convert Sorted Array to Binary Search Tree
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 给定有序数组构造二叉搜索树。考虑到二叉搜索树的性质(中序遍历二叉搜索树可以得到一个排序好的数组) 构造的 阅读全文
posted @ 2017-07-23 17:30 Beserious 阅读(108) 评论(0) 推荐(0) 编辑
107.Binary Tree Level Order Traversal II
摘要:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For 阅读全文
posted @ 2017-07-22 17:29 Beserious 阅读(125) 评论(0) 推荐(0) 编辑
104. Maximum Depth of Binary Tree
摘要:Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l 阅读全文
posted @ 2017-07-21 18:13 Beserious 阅读(108) 评论(0) 推荐(0) 编辑
101. Symmetric Tree
摘要:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmet 阅读全文
posted @ 2017-07-21 17:54 Beserious 阅读(114) 评论(0) 推荐(0) 编辑
100. Same Tree
摘要:Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical a 阅读全文
posted @ 2017-07-21 15:53 Beserious 阅读(121) 评论(0) 推荐(0) 编辑
88. Merge Sorted Array
摘要:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has enough space (size tha 阅读全文
posted @ 2017-07-21 15:29 Beserious 阅读(98) 评论(0) 推荐(0) 编辑
83. Remove Duplicates from Sorted List
摘要:Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, 阅读全文
posted @ 2017-07-20 19:08 Beserious 阅读(110) 评论(0) 推荐(0) 编辑
70. Climbing Stairs
摘要:You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl 阅读全文
posted @ 2017-07-20 18:05 Beserious 阅读(136) 评论(0) 推荐(0) 编辑
69. Sqrt(x)
摘要:Implement int sqrt(int x). Compute and return the square root of x. 二分可解 这里是关于二分的一些总结: 首先,如果题目属于"二分值越大越符合条件",即要求符合条件的最小值,那就是while(r>l){mid=(l+r)/2。。。} 阅读全文
posted @ 2017-07-20 16:32 Beserious 阅读(120) 评论(0) 推荐(0) 编辑
67. Add Binary
摘要:Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 模拟二进制相加,右对齐,然后每位相加....不知道字符串左加和右加对性能有没有影响 阅读全文
posted @ 2017-07-20 13:45 Beserious 阅读(114) 评论(0) 推荐(0) 编辑
66. Plus One
摘要:Given a non-negative integer represented as a non-empty array of digits, plus one to the integer. You may assume the integer do not contain any leadin 阅读全文
posted @ 2017-07-20 11:51 Beserious 阅读(159) 评论(0) 推荐(0) 编辑
58. Length of Last Word
摘要:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word 阅读全文
posted @ 2017-07-20 11:48 Beserious 阅读(94) 评论(0) 推荐(0) 编辑
53. Maximum Subarray
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2, 阅读全文
posted @ 2017-07-20 08:13 Beserious 阅读(117) 评论(0) 推荐(0) 编辑
38. Count and Say
摘要:The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 is read off as "on 阅读全文
posted @ 2017-07-19 21:03 Beserious 阅读(132) 评论(0) 推荐(0) 编辑
35. Search Insert Position
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
posted @ 2017-07-19 20:08 Beserious 阅读(91) 评论(0) 推荐(0) 编辑
28. Implement strStr()
摘要:Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 字符串Rabin--Karp算法。滚动哈希,时间 阅读全文
posted @ 2017-07-19 19:43 Beserious 阅读(92) 评论(0) 推荐(0) 编辑
27. Remove Element
摘要:Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you 阅读全文
posted @ 2017-07-18 16:12 Beserious 阅读(105) 评论(0) 推荐(0) 编辑
26. Remove Duplicates from Sorted Array
摘要:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space fo 阅读全文
posted @ 2017-07-18 16:00 Beserious 阅读(78) 评论(0) 推荐(0) 编辑
21. 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. 注意边界,注意边 阅读全文
posted @ 2017-07-18 15:47 Beserious 阅读(128) 评论(0) 推荐(0) 编辑
20. Valid Parentheses
摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the 阅读全文
posted @ 2017-07-18 13:55 Beserious 阅读(115) 评论(0) 推荐(0) 编辑

上一页 1 ··· 7 8 9 10 11 12 下一页