【Leetcode】Reverse Words in a String JAVA实现
摘要:一、题目描述Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".二、分析要注意几点:1、当字符串的头部或者尾部存...
阅读全文
posted @
2014-10-22 20:20
月下美妞1314
阅读(215)
推荐(0)
【leetcode】Find Minimum in Rotated Sorted Array II JAVA实现
摘要:一、题目描述Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Suppose ...
阅读全文
posted @
2014-10-22 18:57
月下美妞1314
阅读(773)
推荐(0)
【leetcode】Find Minimum in Rotated Sorted Array JAVA实现
摘要:一、题目描述Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum element...
阅读全文
posted @
2014-10-17 22:08
月下美妞1314
阅读(1055)
推荐(0)
【Leetcode】Reorder List JAVA
摘要:一、题目描述Given a singly linked listL: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.Fo...
阅读全文
posted @
2014-10-04 14:57
月下美妞1314
阅读(219)
推荐(0)
【Leetcode】Evaluate Reverse Polish Notation JAVA
摘要:一、问题描述Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another ...
阅读全文
posted @
2014-10-02 22:30
月下美妞1314
阅读(205)
推荐(0)
【Leetcode】Sort List JAVA实现
摘要:Sort a linked list inO(nlogn) time using constant space complexity.1、分析该题主要考查了链接上的合并排序算法。2、正确代码实现package com.edu.leetcode;import com.edu.leetcode.List...
阅读全文
posted @
2014-09-28 23:36
月下美妞1314
阅读(1024)
推荐(0)
Maximum Product Subarray JAVA实现
摘要:题目描述:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,...
阅读全文
posted @
2014-09-25 10:22
月下美妞1314
阅读(350)
推荐(0)
Permutations java实现
摘要:Given a collection of numbers, return all possible permutations.For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,...
阅读全文
posted @
2014-07-08 23:44
月下美妞1314
阅读(427)
推荐(0)
Binary Tree Level Order Traversal java实现
摘要:Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2...
阅读全文
posted @
2014-07-08 22:53
月下美妞1314
阅读(207)
推荐(0)
Merge Two Sorted Lists
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists注:实现这题我想了两种方法,1、将ListNode l2中的结点依次插入到l1中去,每次插入后使l1还是有序的2、使用归并排序在链表上实现的思想1、/** * Definition for singly-linked list. * public class ListNode { * int val; * ...
阅读全文
posted @
2014-03-16 22:05
月下美妞1314
阅读(136)
推荐(0)