leetcode刷题记录
文章平均质量分 76
Platanus_hy
Im Platanus.
展开
-
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 · 936 阅读 · 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.yuandai原创 2014-06-30 16:24:08 · 751 阅读 · 0 评论 -
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 · 534 阅读 · 0 评论 -
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 · 590 阅读 · 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-30 19:29:37 · 549 阅读 · 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.注意:当root的原创 2014-06-30 16:54:44 · 487 阅读 · 0 评论 -
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 · 402 阅读 · 0 评论 -
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 · 462 阅读 · 0 评论 -
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 · 771 阅读 · 0 评论 -
leetcode之Palindrome Number
不使用额外的空间,判断一个给定的数字是否为回文原创 2014-04-21 15:43:08 · 654 阅读 · 0 评论 -
leetcode之Longest Substring Without Repeating Characters
如题,这里的字符串不止是原创 2014-04-20 16:09:57 · 572 阅读 · 0 评论 -
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 · 732 阅读 · 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, w原创 2014-04-19 19:34:35 · 793 阅读 · 0 评论 -
leetcode之Insertion Sort List
Insertion Sort List ,即用插入的方法排序原创 2014-04-19 14:52:48 · 505 阅读 · 0 评论 -
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 · 997 阅读 · 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 eleme原创 2014-07-03 21:22:59 · 589 阅读 · 0 评论