算法学习
文章平均质量分 65
木薏米
这个作者很懒,什么都没留下…
展开
-
JOBDU-1389:变态跳台阶
题目描述:一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。输入:输入可能包含多个测试样例,对于每个测试案例,输入包括一个整数n(1输出:对应每个测试案例,输出该青蛙跳上一个n级的台阶总共有多少种跳法。样例输入:6样例输出:32原创 2014-04-17 14:55:55 · 554 阅读 · 0 评论 -
LeetCode之旅(33)
Linked List Cycle IIGiven a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?原创 2014-08-31 19:20:26 · 340 阅读 · 0 评论 -
LeetCode之旅(28)
Sort ColorsGiven an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will原创 2014-08-30 23:40:43 · 374 阅读 · 0 评论 -
LeetCode之旅(27)
Merge Sorted Array原创 2014-08-30 23:25:34 · 322 阅读 · 0 评论 -
LeetCode之旅(6)
Maximum Depth of Binary Tree原创 2014-08-25 23:47:40 · 379 阅读 · 0 评论 -
LeetCode之旅(26)
Symmetric TreeGiven 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原创 2014-08-29 21:08:01 · 324 阅读 · 0 评论 -
LeetCode之旅(24)
Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use原创 2014-08-29 18:56:14 · 357 阅读 · 0 评论 -
LeetCode之旅(23)
Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.原创 2014-08-29 17:41:29 · 424 阅读 · 0 评论 -
LeetCode之旅(25)
Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear onlyonce and return the new length.Do not allocate extra space for ano原创 2014-08-29 19:33:19 · 408 阅读 · 0 评论 -
LeetCode之旅(12)
Binary Tree Inorder Traversal原创 2014-08-27 14:20:05 · 304 阅读 · 0 评论 -
LeetCode之旅(29)
Plus One原创 2014-08-31 13:12:19 · 345 阅读 · 0 评论 -
LeetCode之旅(38)
Container With Most WaterGiven 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 linei原创 2014-09-04 18:58:37 · 361 阅读 · 0 评论 -
LeetCode之旅(37)
Best Time to Buy and Sell StockSay you have an array for which the ith element is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy原创 2014-09-02 21:52:08 · 328 阅读 · 0 评论 -
LeetCode之旅(36)
Pascal's TriangleGiven numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]原创 2014-09-02 20:52:25 · 354 阅读 · 0 评论 -
LeetCode之旅(35)
Gray CodeThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print t原创 2014-09-02 20:33:42 · 405 阅读 · 0 评论 -
LeetCode之旅(34)
3SumGiven an array S of n integers, are there elementsa, 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 trip原创 2014-09-01 16:59:29 · 363 阅读 · 0 评论 -
LeetCode之旅(32)
Binary Tree Postorder TraversalGiven a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3原创 2014-08-31 17:35:39 · 302 阅读 · 0 评论 -
LeetCode之旅(31)
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the原创 2014-08-31 16:20:22 · 513 阅读 · 0 评论 -
LeetCode之旅(30)
Two SumGiven 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 th原创 2014-08-31 15:24:11 · 330 阅读 · 0 评论 -
LeetCode之旅(22)
Balanced Binary Tree原创 2014-08-29 16:06:44 · 298 阅读 · 0 评论 -
LeetCode之旅(15)
Remove Duplicates from Sorted ListGiven a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, r原创 2014-08-28 14:15:02 · 291 阅读 · 0 评论 -
LeetCode之旅(5)
Single Number原创 2014-08-25 23:19:55 · 334 阅读 · 0 评论 -
LeetCode之旅(9)
Unique Binary Search TreesGiven 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.原创 2014-08-26 21:50:10 · 324 阅读 · 0 评论 -
LeetCode之旅(8)
Reverse IntegerReverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321原创 2014-08-26 00:20:10 · 353 阅读 · 0 评论 -
LeetCode之旅(7)
Same Tree原创 2014-08-25 23:58:45 · 318 阅读 · 0 评论 -
LeetCode之旅(4)
Sort ListSort a linked list in O(n log n) time using constant space complexity.原创 2014-08-25 22:17:42 · 456 阅读 · 0 评论 -
LeetCode之旅(3)
Max Points on a LineGiven n points on a 2D plane, find the maximum number of points that lie on the same straight line.原创 2014-08-24 11:57:49 · 439 阅读 · 0 评论 -
LeetCode之旅(1)
Reverse Words in a String原创 2014-08-24 10:42:48 · 424 阅读 · 0 评论 -
LeetCode之旅(2)
Evaluate Reverse Polish NotationEvaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expressi原创 2014-08-24 10:46:51 · 366 阅读 · 0 评论 -
LeetCode之旅(10)
Linked List Cycle原创 2014-08-26 22:53:38 · 291 阅读 · 0 评论 -
LeetCode之旅(11)
Binary Tree Preorder Traversal原创 2014-08-27 13:34:23 · 403 阅读 · 0 评论 -
LeetCode之旅(17)
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.很无聊的一道题,不过原创 2014-08-28 14:35:48 · 292 阅读 · 0 评论 -
LeetCode之旅(16)
Climbing StairsYou are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?经典的跳台原创 2014-08-28 14:21:41 · 1298 阅读 · 0 评论 -
LeetCode之旅(14)
Search Insert Position原创 2014-08-28 14:01:55 · 313 阅读 · 0 评论 -
LeetCode之旅(20)
Merge Two Sorted Lists原创 2014-08-28 18:34:10 · 535 阅读 · 0 评论 -
LeetCode之旅(18)
Integer to RomanGiven an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.原创 2014-08-28 14:49:19 · 310 阅读 · 0 评论 -
LeetCode之旅(21)
Remove Element原创 2014-08-28 19:00:31 · 288 阅读 · 0 评论 -
LeetCode之旅(19)
Maximum Subarray原创 2014-08-28 18:21:16 · 304 阅读 · 0 评论 -
LeetCode之旅(13)
Populating Next Right Pointers in Each NodeGiven a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each n原创 2014-08-27 15:56:25 · 283 阅读 · 0 评论 -
LeetCode之旅(39)
Best Time to Buy and Sell Stock IISay you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as原创 2014-09-04 19:55:15 · 397 阅读 · 0 评论