- 博客(20)
- 资源 (3)
- 收藏
- 关注
原创 Leetcode Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node's key.
2014-06-26 14:50:10 667
原创 LeetCode 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 does not exist, return 0.Note: A word is d
2014-06-26 14:44:32 635
原创 LeetCode 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 no
2014-06-26 14:41:07 649
原创 LeetCode Reverse Integer
题目链接:Reverse Integer Total Accepted: 19460 Total Submissions: 48827My SubmissionsReverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321
2014-06-06 19:53:28 611
原创 LeetCode Implement strStr()
题目链接:https://oj.leetcode.com/problems/implement-strstr/Implement strStr() Total Accepted: 11761 Total Submissions: 55407My SubmissionsImplement strStr().Returns a pointer t
2014-06-06 19:51:08 495
原创 LeetCode Remove Element
Remove Element Total Accepted: 15233 Total Submissions: 47017My SubmissionsGiven an array and a value, remove all instances of that value in place and return the new length.The order o
2014-06-06 19:49:12 540
原创 leetcode Search Insert Position
题目链接:https://oj.leetcode.com/problems/search-insert-position/Search Insert Position Total Accepted: 15858 Total Submissions: 45831My SubmissionsGiven a sorted array and a
2014-06-06 19:46:59 556
原创 Leetcode Pow(x, n)
题目链接:https://oj.leetcode.com/problems/powx-n/Pow(x, n) Total Accepted: 14246 Total Submissions: 55043My SubmissionsImplement pow(x, n).Have you been asked t
2014-06-06 19:45:00 708
原创 leetcode Remove Duplicates from Sorted Array II
题目链接:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/Remove Duplicates from Sorted Array II Total Accepted: 11786 Total Submissions: 39043My Submissions
2014-06-06 19:41:10 750
原创 Leetcode Multiply Strings
题目链接:https://oj.leetcode.com/problems/multiply-strings/Multiply Strings Total Accepted: 8084 Total Submissions: 40447My SubmissionsGiven two numbers represented as string
2014-06-06 19:37:08 731
原创 Manacher算法--O(n)内求回文子串
昨天做了leetcode里的 Longest Palindromic Substring ,一开始用动态规划O(N^2),不管怎么改都超时了。。。于是在大神的帮助下,找到了传说中的Manacher算法,居然能在O(n)内求出来,瞬间给跪了。本屌认为,这个算法主要是充分的利用了以前的匹配的结果,来起到了降低时间复杂度的作用,这点跟KMP算是有点类似。在预处理时有个小技巧就是将第0,1为设
2014-06-05 12:17:42 1401
原创 二叉树类
上学期数据结构课上写的一个二叉树类,贴出来,写得不是太好,欢迎高手指点。struct BiNode//定义节点类型 { char data; BiNode *lchild; BiNode *rchild;};class BiTree{ private: BiNode *root; public: BiTree() { root=NULL; } ~BiT
2014-06-04 10:57:21 731
原创 LeetCode Same Tree
题目链接:https://oj.leetcode.com/submissions/detail/6968674/
2014-06-01 21:00:41 513
原创 LeetCode Sqrt(x)
题目链接:https://oj.leetcode.com/problems/sqrtx/Implement int sqrt(int x).Compute and return the square root of x.这学期上计算方法的时候刚讲过,采用牛顿迭代法 计算x2 = n的解,令f(x)=x2-n,相当于求解f(x)=0的解.经过(xi
2014-06-01 20:54:45 891
原创 LeetCode Reverse Integer
题目链接:https://oj.leetcode.com/problems/reverse-integer/Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321不解释
2014-06-01 20:48:08 526
原创 LeetCode Search a 2D Matrix
题目链接:https://oj.leetcode.com/problems/search-a-2d-matrix/Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers
2014-06-01 20:46:19 822
原创 LeetCode Set Matrix Zeroes
题目链接:https://oj.leetcode.com/problems/set-matrix-zeroes/Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.一个个找肯定会超时,我们可以分别用一个行向量和一个列向量进行维护。这样
2014-06-01 20:41:17 897
原创 LeetCode Merge Two Sorted Lists
题目链接:https://oj.leetcode.com/problems/merge-two-sorted-lists/合并两个有序链表,不解释
2014-06-01 20:37:47 701
原创 LeetCode Maximum Subarray
题目链接:https://oj.leetcode.com/problems/maximum-subarray/
2014-06-01 20:36:00 524
原创 LeetCode Sort Colors
class Solution {public: void swap(int &a,int &b) { int t=a; a=b; b=t; } void ksort(int l,int h,int a[]) { if(h<l+2) return; int e=h,p=l; while(
2014-06-01 20:32:38 805
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人