![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetCode
文章平均质量分 77
kgblily205
这个作者很懒,什么都没留下…
展开
-
leetCode:Single Number
Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra原创 2014-09-06 16:14:50 · 422 阅读 · 0 评论 -
leetCode:Longest Substring Without Repeating Characters
#include#include#includeusing namespace std;class Solution{public: int lengthOfLongestSubstring(string s){ int length=s.size(); map charmap; int maxLen=0,lastindex=-1转载 2014-09-24 10:39:58 · 514 阅读 · 0 评论 -
字符串操作
自己写的,还有一些不全面#include#includeint StrLength(char[]);int Concat(char* T,char s1[],char s2[]);int Index(char S[],char T[],int pos);char *reverse(char*,int);int main(){ char a1[11]="abcdefghij原创 2014-09-12 20:23:46 · 465 阅读 · 0 评论 -
leetCode:Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.原创 2014-09-10 16:34:43 · 476 阅读 · 0 评论 -
leetCode: two Sum
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, where原创 2014-09-22 09:56:02 · 492 阅读 · 0 评论 -
leetCode: BInary 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 order.You may assume no duplicates in the array.原创 2014-09-09 20:20:50 · 456 阅读 · 0 评论 -
leetCode:Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "1", "+",原创 2014-09-21 15:16:58 · 471 阅读 · 0 评论 -
leetCode:Path Sum
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 and sum原创 2014-09-08 00:43:25 · 498 阅读 · 0 评论 -
leetCode:Pascal's Triangle II
#include#includeusing namespace std;class Solution{public: vector generate(int numRows){ vector > temp; if(numRows<=0) return temp[numRows]; for(int i=0;i<numRows+1;i原创 2014-09-07 21:11:45 · 451 阅读 · 0 评论 -
leetCode:Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.原创 2014-09-08 02:17:03 · 490 阅读 · 0 评论 -
leetCode: binary tree sum
题目是:有一颗二叉树,每个节点都是0~9转载 2014-09-06 18:28:34 · 386 阅读 · 0 评论 -
leetCode:Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before coding.原创 2014-09-08 04:13:56 · 430 阅读 · 0 评论 -
leetCode:Linked List Cycle II
Given a 2D board containing 'X' and 'O', capture all regions surrounded by'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X XX O O XX X原创 2014-09-07 11:35:34 · 490 阅读 · 0 评论 -
n节点组成二叉树的个数
可以分析,当n=1时,只有1个根节点,则只能组成1种形态的二叉树,令n个节点可组成的二叉树数量表示为h(n),则h(1)=1; h(0)=0; 当n=2时,1个根节点固定,还有2-1个节点。这一个节点可以分成(1,0),(0,1)两组。即左边放1个,右边放0个;或者左边放0个,右边放1个。即:h(2)=h(0)*h(1)+h(1)*h(0)=2,则能组成2种形态的二叉转载 2014-09-07 00:17:24 · 1310 阅读 · 0 评论 -
leetCode: 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.转载 2014-09-06 23:27:51 · 418 阅读 · 0 评论 -
leetCode:Palindrome Number
Palindrome NumberTotal Accepted: 22288 Total Submissions: 76684 Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could nega原创 2014-09-25 22:18:54 · 425 阅读 · 0 评论