![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
文章平均质量分 60
阿萨德发的阿达
这个作者很懒,什么都没留下…
展开
-
Path Sum II --路径和(重)
问题:liGiven a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5原创 2014-06-24 20:23:51 · 385 阅读 · 0 评论 -
Balanced Binary Tree --判断平衡二叉树(重重)
问题:链接Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node原创 2014-06-23 21:13:16 · 462 阅读 · 0 评论 -
Linked List Cycle --判断链表是否有环
问题:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?解答:快慢指针。代码:/** * Definition for singly-linked list. * struct ListNo原创 2014-06-24 19:38:25 · 402 阅读 · 0 评论 -
Count and Say
问题:链接原创 2014-06-23 17:05:46 · 724 阅读 · 0 评论 -
Length of Last Word --最后单词长度---如何优雅的写代码(重重)
问题:链接代码:class Solution {public: int lengthOfLastWord(const char *s) { int n = strlen(s) - 1; while(n>=0 && s[n] == ' ') n--; int i = 0; for(; n>=0 && s[n] != ' '; n--, i++); r原创 2014-06-23 21:56:23 · 558 阅读 · 0 评论 -
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 no原创 2014-06-24 21:59:45 · 407 阅读 · 0 评论 -
Merge Sorted Array -- 合并两个有序数组
问题:链接Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal to m + n) to hold additional ele原创 2014-06-24 23:14:38 · 330 阅读 · 0 评论 -
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原创 2014-06-24 20:07:07 · 344 阅读 · 0 评论 -
Valid Parentheses --括号匹配
问题:链接Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" a原创 2014-06-22 10:04:35 · 319 阅读 · 0 评论 -
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-06-20 11:36:26 · 417 阅读 · 0 评论 -
Palindrome Number --回文整数
问题:链接Determine whether an integer is a palindrome. Do this without extra space.原创 2014-06-21 23:13:51 · 341 阅读 · 0 评论 -
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原创 2014-06-21 23:05:23 · 346 阅读 · 0 评论 -
ZigZag Conversion-锯齿形数组 查找数学规律
链接:https://oj.leetcode.com/problems/zigzag-conversion/查找规律的题目,数学差,做起来真吃力。原创 2014-06-21 11:14:25 · 580 阅读 · 0 评论 -
single num--唯一一个只出现一次 的数
问题:Given an array of integers, every element appears twice except for one. Find that single one.解答原创 2014-06-21 22:59:58 · 555 阅读 · 0 评论 -
Remove Duplicates from Sorted List --已出有序链表中的重复元素
问题: 链接原创 2014-06-21 23:07:34 · 322 阅读 · 0 评论 -
Longest Common Prefix -最长公共前缀
问题:链接Write a function to find the longest common prefix string amongst an array of strings.解答:注意 当传入参数为空,ji原创 2014-06-22 01:03:01 · 487 阅读 · 0 评论 -
Container With Most Water --装最多水的容器(重)
问题:链接Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i,原创 2014-06-22 00:19:00 · 441 阅读 · 0 评论 -
Remove Element--原地移除重复元素
问题:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new len原创 2014-06-22 16:50:03 · 399 阅读 · 0 评论 -
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 ta原创 2014-06-20 12:49:10 · 318 阅读 · 0 评论 -
Letter Combinations of a Phone Number
问题:链接Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.原创 2014-06-22 02:06:04 · 505 阅读 · 0 评论 -
Maximum Depth of Binary Tree 二叉树的最大深度(重)
wenGiven 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 leaf node.原创 2014-06-19 23:33:33 · 416 阅读 · 0 评论 -
Single Number II --出现一次的数(重)
问题:Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it wi原创 2014-06-22 09:15:29 · 407 阅读 · 0 评论 -
Longest Substring Without Repeating Characters--最长无重复字符串(重)
这个真没搞太懂 改天搞原创 2014-06-20 23:59:03 · 375 阅读 · 0 评论 -
Median of Two Sorted Arrays - 寻找两个有序数组的中位数(重)
问题:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).解答:这道题原创 2014-06-20 21:10:02 · 639 阅读 · 0 评论 -
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 for another array, you must do this in原创 2014-06-22 16:53:33 · 434 阅读 · 0 评论 -
Search Insert Position--寻找插入点Given a sorted array and a target value, return the index if the target
问题: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 t原创 2014-06-22 17:26:34 · 941 阅读 · 0 评论 -
Binary Tree Preorder Traversal -先序遍历
问题:链接Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].Note: Recur原创 2014-06-22 18:12:09 · 352 阅读 · 0 评论 -
Remove Nth Node From End of List --移除链表中的倒数第k个元素
问题:链接原创 2014-06-21 23:10:44 · 364 阅读 · 0 评论 -
Reverse Integer--反转整数
问题:链接原创 2014-06-21 23:29:46 · 340 阅读 · 0 评论 -
Binary Tree Postorder Traversal --二叉树非递归后序遍历(重重)
问题:链接Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recu原创 2014-06-23 09:48:36 · 514 阅读 · 0 评论 -
Search for a Range--查找某个数范围--二分查找
问题:链接Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is原创 2014-06-23 10:27:22 · 434 阅读 · 0 评论 -
Generate Parentheses--生成匹配括号(重)
问题:链接Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(原创 2014-06-22 11:25:25 · 574 阅读 · 0 评论 -
Insertion Sort List 链表插入排序
题目:Sort a linked list using insertion sort.原创 2014-08-05 20:25:08 · 319 阅读 · 0 评论 -
Linked List Cycle II
http://blog.csdn.net/kenden23/article/details/13871699转载 2014-08-05 21:57:04 · 255 阅读 · 0 评论 -
Subsets II
题目:https://oj.leetcode.com/problems/subsets-ii/原创 2014-08-19 11:18:28 · 289 阅读 · 0 评论 -
Subsets 深搜
问题:链接解答:典型的深搜解决。代码:原创 2014-08-19 00:08:25 · 333 阅读 · 0 评论 -
Symmetric Tree --镜像树(重)
题目:链接解答:采用递归, 根据定义,一个树是镜像树,那么原创 2014-08-19 11:01:47 · 373 阅读 · 0 评论 -
Combinations 搜索(重重)
题目:链接解答原创 2014-08-18 23:05:22 · 369 阅读 · 0 评论 -
Flatten Binary Tree to Linked List 将二叉树转换为链表
题目:链接解答:先序遍历,将遍历的值插入到weizhi原创 2014-08-21 00:08:40 · 288 阅读 · 0 评论 -
Edit Distance 字符串距离(重重)
题目:链接解答:编程之美上有解答,如果采用递归的方法,会超时。jied原创 2014-08-20 00:19:41 · 349 阅读 · 0 评论