摘要: 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]retur... 阅读全文
posted @ 2015-08-24 09:40 李小橘er 阅读(317) 评论(0) 推荐(0)
摘要: 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).You are given a target value t... 阅读全文
posted @ 2015-08-21 16:28 李小橘er 阅读(138) 评论(0) 推荐(0)
摘要: Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a... 阅读全文
posted @ 2015-08-21 13:43 李小橘er 阅读(246) 评论(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-08-21 11:39 李小橘er 阅读(304) 评论(2) 推荐(0)
摘要: 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.You m... 阅读全文
posted @ 2015-08-21 10:29 李小橘er 阅读(175) 评论(0) 推荐(0)
摘要: 这道题我觉得难点就是在到底咋用java判断一个数是不是质数这个点上。 说实话这个我实在没啥点,我这个办法也是直接死背下来的,所以我也不会说原理。 关于isPrime()method里面那个for loop为啥step是2是因为我的loopcong3开始,3,5,7,9……这样是略过了所有偶数... 阅读全文
posted @ 2015-08-20 16:04 李小橘er 阅读(224) 评论(0) 推荐(0)
摘要: Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:You may assume thatnums1has enough space (size that is great... 阅读全文
posted @ 2015-08-20 14:02 李小橘er 阅读(150) 评论(0) 推荐(0)
摘要: Given an integer, write a function to determine if it is a power of two. 这道题没啥难度。主要是搞清楚怎么来判断一个数是不是power of two。 最简单的方法就是一直除以2最后等于1。如果不能,那么都是false。 ... 阅读全文
posted @ 2015-08-20 12:51 李小橘er 阅读(182) 评论(0) 推荐(0)
摘要: Given an integer array of sizen, find all elements that appear more than⌊ n/3 ⌋times. The algorithm should run in linear time and in O(1) space. 这道题就... 阅读全文
posted @ 2015-08-20 11:21 李小橘er 阅读(131) 评论(0) 推荐(0)
摘要: 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.Fo... 阅读全文
posted @ 2015-08-20 09:52 李小橘er 阅读(172) 评论(0) 推荐(0)