leetCode
临江别寄
软件工程专业
展开
-
Largest Number
Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The result may be ve原创 2016-03-04 21:48:32 · 413 阅读 · 0 评论 -
Bulls and Cows
You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint t原创 2016-12-31 14:18:35 · 437 阅读 · 0 评论 -
Count and Say
LeetCode The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is原创 2016-12-30 16:13:26 · 389 阅读 · 0 评论 -
Pascal's Triangle
Given 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]]杨辉三角,题目本身很简单。具体我就不解释了,首先简单原创 2017-01-04 21:02:30 · 431 阅读 · 0 评论 -
Divide Two Integers
题目 : Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.我们不实用除法进行整数除法运算,如果溢出的话,我们就返回整形的最大值。1、我们第一想到的是直接相减(a, b),被除数不断的减去除数看最多能减几次原创 2016-12-26 22:12:56 · 478 阅读 · 0 评论 -
Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary原创 2017-01-03 16:45:09 · 385 阅读 · 0 评论 -
Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3,9,20,null,null,1原创 2017-01-03 16:26:13 · 412 阅读 · 0 评论 -
Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 2原创 2017-01-02 21:36:54 · 344 阅读 · 0 评论 -
Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]原创 2017-01-02 17:30:36 · 373 阅读 · 0 评论 -
First Missing Positive
Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant原创 2016-03-01 10:05:27 · 379 阅读 · 0 评论 -
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.For example:Given the below binary tree and sum原创 2016-12-31 14:56:51 · 356 阅读 · 0 评论