leetcode
酱油p
这个作者很懒,什么都没留下…
展开
-
【leetcode】Remove Duplicates from Sorted Array II
Remove Duplicates from Sorted Array IIFollow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your f原创 2014-08-03 19:37:42 · 330 阅读 · 0 评论 -
【leetcode】3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact原创 2014-08-12 23:15:30 · 354 阅读 · 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 c原创 2014-07-31 19:59:01 · 321 阅读 · 0 评论 -
【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 ext原创 2014-07-30 21:21:34 · 349 阅读 · 0 评论 -
【leetcode】Maximum Depth of Binary Tree
Given 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-08-05 22:10:21 · 370 阅读 · 0 评论 -
【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原创 2014-08-04 22:16:59 · 349 阅读 · 0 评论 -
【leetcode】Symmetric Tree
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 / \ 2 2 / \ / \3 4 4 3But the f原创 2014-08-05 20:58:38 · 366 阅读 · 0 评论 -
【leetcode】Plus One
Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.class Solution {pub原创 2014-08-05 20:54:05 · 332 阅读 · 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-07-30 21:54:02 · 352 阅读 · 0 评论 -
【leetcode】Maximum Depth of Binary Tree
Given 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-07-30 21:25:40 · 320 阅读 · 0 评论 -
【leetcode】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 length.原创 2014-08-04 21:43:40 · 358 阅读 · 0 评论 -
【leetcode】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-08-03 22:16:56 · 331 阅读 · 0 评论 -
【leetcode】Search in Rotated Sorted Array II
Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the原创 2014-08-03 21:19:46 · 324 阅读 · 0 评论 -
【leetcode】Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array retur原创 2014-08-03 20:10:19 · 343 阅读 · 0 评论 -
【leetcode】
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c原创 2014-08-12 21:53:25 · 347 阅读 · 0 评论