
leetcode
文章平均质量分 64
sddyljsx
这个作者很懒,什么都没留下…
展开
-
1、Two Sum
class Solution { public: vector twoSum(vector &numbers, int target) { for(int i=0;i for(int j=i+1;j if(numbers[i]+numbers[j]==target){原创 2015-03-24 09:56:15 · 581 阅读 · 0 评论 -
96. Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example, Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \原创 2017-08-26 17:38:34 · 244 阅读 · 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 and the nodes have the same value. # Defi原创 2017-08-26 17:15:50 · 256 阅读 · 0 评论 -
97. Interleaving String
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example, Given: s1 = "aabcc", s2 = "dbbca", When s3 = "aadbbcbcac", return true. When s3 = "aadbbbaccc", retur原创 2017-08-26 17:01:01 · 242 阅读 · 0 评论 -
98. 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.Th原创 2017-08-26 15:36:53 · 249 阅读 · 0 评论 -
87.Scramble String
public class Solution { public boolean isScramble(String s1, String s2) { int n=s1.length(); boolean[][][] dp=new boolean[n][n][n+1]; for(int i=n-1; i>=0原创 2015-08-11 10:15:05 · 508 阅读 · 0 评论 -
5、Longest Palindromic Substring
题目如下: Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 分转载 2015-04-13 21:42:19 · 1118 阅读 · 0 评论 -
3、Longest Substring Without Repeating Characters
class Solution { public: int lengthOfLongestSubstring(string s) { map stringMap; int i=0; int length=0; while(char ch=s[i]){原创 2015-03-24 15:23:57 · 504 阅读 · 0 评论 -
2、Add Two Numbers
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: Li原创 2015-03-24 14:36:25 · 451 阅读 · 0 评论 -
95. Unique Binary Search Trees II
Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example, Given n = 3, your program should return all 5 unique BST's shown below. 1原创 2017-08-26 18:56:29 · 233 阅读 · 0 评论