随笔分类 -  leetcode

1
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *... 阅读全文
posted @ 2014-09-18 16:18 海滨银枪小霸王 阅读(105) 评论(0) 推荐(0)
摘要:Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters. For example, the ... 阅读全文
posted @ 2014-09-18 14:30 海滨银枪小霸王 阅读(121) 评论(0) 推荐(0)
摘要:自己整理一下leetcode的list.时时列1. Longest Substring Without Repeating Characters最长不重复子串2. 阅读全文
posted @ 2014-09-18 10:36 海滨银枪小霸王 阅读(159) 评论(0) 推荐(0)
摘要:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for a... 阅读全文
posted @ 2014-06-22 16:59 海滨银枪小霸王 阅读(82) 评论(0) 推荐(0)
摘要:Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"((()))... 阅读全文
posted @ 2014-06-22 02:48 海滨银枪小霸王 阅读(105) 评论(0) 推荐(0)
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for singly-linked list. ... 阅读全文
posted @ 2014-06-22 02:28 海滨银枪小霸王 阅读(127) 评论(0) 推荐(0)
摘要:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree./** * Definiti... 阅读全文
posted @ 2014-06-21 23:43 海滨银枪小霸王 阅读(141) 评论(0) 推荐(0)
摘要:Given preorder and inorder traversal of a tree, construct the binary tree./** * Definition for binary tree * struct TreeNode { * int val; * Tr... 阅读全文
posted @ 2014-06-21 23:29 海滨银枪小霸王 阅读(135) 评论(0) 推荐(0)
摘要: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 n... 阅读全文
posted @ 2014-06-21 21:32 海滨银枪小霸王 阅读(138) 评论(0) 推荐(0)
摘要:class Solution {public: int threeSumClosest(vector &num, int target) { int len = num.size(); sort(num.begin(),num.end()); i... 阅读全文
posted @ 2014-06-05 09:15 海滨银枪小霸王 阅读(117) 评论(0) 推荐(0)
摘要:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(... 阅读全文
posted @ 2014-06-05 07:55 海滨银枪小霸王 阅读(113) 评论(0) 推荐(0)
摘要:class Solution {public: string longestCommonPrefix(vector &strs) { int size = strs.size(); if(size==0) return ""; ... 阅读全文
posted @ 2014-06-04 15:04 海滨银枪小霸王 阅读(108) 评论(0) 推荐(0)
摘要:class Solution {public: int atoi(const char *str) { bool negative = false; while(*str==' ')str++ ; if(*str=='-') ... 阅读全文
posted @ 2014-06-04 11:57 海滨银枪小霸王 阅读(119) 评论(0) 推荐(0)
摘要:Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".Have you been asked this question in an intervi... 阅读全文
posted @ 2014-04-06 18:55 海滨银枪小霸王 阅读(122) 评论(0) 推荐(0)
摘要:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ... 阅读全文
posted @ 2014-04-01 15:24 海滨银枪小霸王 阅读(151) 评论(0) 推荐(0)
摘要:Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文
posted @ 2014-03-28 00:02 海滨银枪小霸王 阅读(127) 评论(0) 推荐(0)
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for binary tree * struct TreeNode { ... 阅读全文
posted @ 2014-03-27 23:43 海滨银枪小霸王 阅读(99) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest ... 阅读全文
posted @ 2014-03-08 21:11 海滨银枪小霸王 阅读(136) 评论(0) 推荐(0)
摘要:Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2... 阅读全文
posted @ 2014-03-08 19:16 海滨银枪小霸王 阅读(131) 评论(0) 推荐(0)
摘要:Implement pow(x,n).第一个版本:double pow(double x, int n){ if(n==0) return 1.0; if(n0) { if(n%2==0) return pow(x, n/2) *... 阅读全文
posted @ 2014-03-08 18:18 海滨银枪小霸王 阅读(145) 评论(0) 推荐(0)

1