摘要: Write an algorithm which computes the number of trailing zeros in n factorial. 11! = 39916800, so the out should be 2 这道题的思路比较诡异,结尾要有0的话,必须要有质因数2和质因数5 阅读全文
posted @ 2016-03-07 17:43 哥布林工程师 阅读(102) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, swap every two adjacent nodes and return its head. Given 1->2->3->4, you should return the list as 2->1->4->3. /** * Definition f 阅读全文
posted @ 2016-03-07 08:44 哥布林工程师 阅读(94) 评论(0) 推荐(0) 编辑
摘要: You have two every large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of 阅读全文
posted @ 2016-03-07 08:15 哥布林工程师 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Given an integer array, find a subarray where the sum of numbers is zero. Your code should return the index of the first number and the index of the l 阅读全文
posted @ 2016-03-07 08:04 哥布林工程师 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Implement int sqrt(int x). Compute and return the square root of x. sqrt(3) = 1 sqrt(4) = 2 sqrt(5) = 2 sqrt(10) = 3 mid*mid 以及 (mid + 1) * (mid + 1)都 阅读全文
posted @ 2016-03-07 07:53 哥布林工程师 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Write a method to replace all spaces in a string with%20. The string is given in a characters array, you can assume it has enough space for replacemen 阅读全文
posted @ 2016-03-07 07:29 哥布林工程师 阅读(149) 评论(0) 推荐(0) 编辑
摘要: Singleton is a most widely used design pattern. If a class has and only has one instance at every moment, we call this design as singleton. For exampl 阅读全文
posted @ 2016-03-07 07:11 哥布林工程师 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Given 2*n + 1 numbers, every numbers occurs twice except one, find it. Given [1,2,2,1,3,4,3], return 4 因为所有数都出现了两次,只有一个出现一次,所以只要把所有数做XOR,就可以得到出现一次的数 p 阅读全文
posted @ 2016-03-07 07:05 哥布林工程师 阅读(80) 评论(0) 推荐(0) 编辑
摘要: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted f 阅读全文
posted @ 2016-03-07 07:03 哥布林工程师 阅读(182) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
posted @ 2016-03-07 06:54 哥布林工程师 阅读(177) 评论(0) 推荐(0) 编辑
摘要: Given a string and an offset, rotate string by offset. (rotate from left to right) Given "abcdefg". offset=0 => "abcdefg" offset=1 => "gabcdef" offset 阅读全文
posted @ 2016-03-07 06:37 哥布林工程师 阅读(328) 评论(0) 推荐(0) 编辑
摘要: Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the". Clarification What constitut 阅读全文
posted @ 2016-03-07 06:11 哥布林工程师 阅读(140) 评论(0) 推荐(0) 编辑