- 博客(17)
- 收藏
- 关注
原创 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 eleme
2014-07-03 21:22:59 590
原创 Convert Sorted Array to Binary Search Tree
题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.源代码:public class Solution { public TreeNode sortedArrayToBST(int[] num) { if(num
2014-07-03 20:16:22 535
原创 Valid Palindrome
题目:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car"
2014-07-01 14:25:42 591
原创 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-30 19:29:37 550
原创 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.注意:当root的
2014-06-30 16:54:44 490
原创 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.yuandai
2014-06-30 16:24:08 752
原创 leetcode之Best Time to Buy and Sell Stock II
Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multipl
2014-05-14 17:43:23 403
原创 leetcode之Best Time to Buy and Sell Stock
题目:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the
2014-05-12 09:42:01 463
原创 leetcode 之 Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.思路:首先找到
2014-04-22 15:52:06 772
原创 leetcode之String to Integer
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca
2014-04-21 14:14:08 733
原创 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, w
2014-04-19 19:34:35 794
原创 leetcode之时间复杂度为O(nlogn)的链表排序
3. Sort ListSort a linked list in O(n log n) time using constant space complexity.
2014-04-18 15:14:42 1001
原创 leetcode刷题源代码记录
public String reverseWords(String s) { if(s.equals(""))return ""; Stack stack = new Stack();StringBuilder results = new StringBuilder();for(String str : s.split(" ")){ if(str.equals("")) continue;stac
2014-04-14 19:19:50 937
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人