摘要: 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,... 阅读全文
posted @ 2015-11-28 22:21 djiankuo 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Given 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, ... 阅读全文
posted @ 2015-11-28 21:35 djiankuo 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 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./** * Def... 阅读全文
posted @ 2015-11-28 20:43 djiankuo 阅读(131) 评论(0) 推荐(0) 编辑
摘要: Implement the following operations of a queue using stacks.push(x) – Push element x to the back of queue. pop() – Removes the element from in front of... 阅读全文
posted @ 2015-11-28 20:03 djiankuo 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 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 ... 阅读全文
posted @ 2015-11-28 19:42 djiankuo 阅读(150) 评论(0) 推荐(0) 编辑
摘要: Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer... 阅读全文
posted @ 2015-11-28 17:43 djiankuo 阅读(146) 评论(0) 推荐(0) 编辑
摘要: The 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 numb... 阅读全文
posted @ 2015-11-28 16:54 djiankuo 阅读(173) 评论(0) 推荐(0) 编辑
摘要: Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For exam... 阅读全文
posted @ 2015-11-28 16:03 djiankuo 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Given a sorted linked list, delete all duplicates such that each element appear only once.For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3... 阅读全文
posted @ 2015-11-28 15:51 djiankuo 阅读(108) 评论(0) 推荐(0) 编辑
摘要: Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.Yo... 阅读全文
posted @ 2015-11-28 15:30 djiankuo 阅读(145) 评论(0) 推荐(0) 编辑
摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1... 阅读全文
posted @ 2015-11-28 14:54 djiankuo 阅读(120) 评论(0) 推荐(0) 编辑
摘要: You 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 cli... 阅读全文
posted @ 2015-11-28 14:14 djiankuo 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes... 阅读全文
posted @ 2015-11-26 20:34 djiankuo 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space?Subscribeto see which companies asked thi... 阅读全文
posted @ 2015-11-25 21:07 djiankuo 阅读(139) 评论(0) 推荐(0) 编辑
摘要: Given an array containingndistinct numbers taken from0, 1, 2, ..., n, find the one that is missing from the array. For example,Givennums=[0, 1, 3]retu... 阅读全文
posted @ 2015-11-25 20:42 djiankuo 阅读(169) 评论(0) 推荐(0) 编辑
摘要: Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit in... 阅读全文
posted @ 2015-11-25 20:21 djiankuo 阅读(327) 评论(0) 推荐(0) 编辑
摘要: Related to questionExcel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A ... 阅读全文
posted @ 2015-11-25 16:22 djiankuo 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 ->... 阅读全文
posted @ 2015-11-25 14:10 djiankuo 阅读(179) 评论(0) 推荐(0) 编辑
摘要: int main(int argc,char* argv[])详解摘自网络 argc是命令行总的参数个数argv[]是argc个参数,其中第0个参数是程序的全名,以后的参数命令行后面跟的用户输入的参数,比如:intmain(intargc,char*argv[]){inti;for(i=0;i>i;... 阅读全文
posted @ 2015-10-23 14:59 djiankuo 阅读(952) 评论(0) 推荐(0) 编辑