随笔分类 -  Algorithm

1 2 3 4 5 ··· 16 下一页
classic algorithm, problem
摘要:赠券收集者问题(coupon collector's problem),就是买东西的时候会又不同的卡片赠送,求集齐这些卡片需要购买的产品的数量的期望值。 见wiki [coupon collector's problem https://en.wikipedia.org/wiki/Coupon_co... 阅读全文
posted @ 2015-10-16 21:04 卖程序的小歪 阅读(2041) 评论(0) 推荐(2)
摘要:Given an directed graph, a topological order of the graph nodes is defined as follow: For each directed edge A B in graph, A must before B in the ord... 阅读全文
posted @ 2015-10-12 22:58 卖程序的小歪 阅读(149) 评论(0) 推荐(0)
摘要:Given a root of Binary Search Tree with unique value for each node. Remove the node with given value. If there is no such a node with given value in ... 阅读全文
posted @ 2015-09-23 17:10 卖程序的小歪 阅读(186) 评论(0) 推荐(0)
摘要:Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is called 'serialization' and reading back ... 阅读全文
posted @ 2015-09-23 16:47 卖程序的小歪 阅读(269) 评论(0) 推荐(0)
摘要:Given two values k1 and k2 (where k1 < k2) and a root pointer to a Binary Search Tree. Find all the keys of tree in range k1 to k2. i.e. print all x ... 阅读全文
posted @ 2015-09-23 16:17 卖程序的小歪 阅读(190) 评论(0) 推荐(0)
摘要:Given an array of integers, the majority number is the number that occurs more than 1/3 of the size of the array. Find it. Have you met this question... 阅读全文
posted @ 2015-09-19 21:15 卖程序的小歪 阅读(259) 评论(0) 推荐(0)
摘要:Given 2 n + 2 numbers, every numbers occurs twice except two, find them. Have you met this question in a real interview? Yes Example Given [1,2,2,3,4... 阅读全文
posted @ 2015-09-17 16:18 卖程序的小歪 阅读(111) 评论(0) 推荐(0)
摘要:Given string A representative a positive integer which has N digits, remove any k digits of the number, the remaining digits are arranged according t... 阅读全文
posted @ 2015-09-17 15:06 卖程序的小歪 阅读(144) 评论(0) 推荐(0)
摘要:Given a (decimal e.g. 3.72) number that is passed in as a string, return the binary representation that is passed in as a string. If the fractional p... 阅读全文
posted @ 2015-09-15 00:25 卖程序的小歪 阅读(195) 评论(0) 推荐(0)
摘要:Calculate the an % b where a, b and n are all 32bit integers. Have you met this question in a real interview? Yes Example For 231 % 3 = 2 For 1001000... 阅读全文
posted @ 2015-09-14 00:37 卖程序的小歪 阅读(138) 评论(0) 推荐(0)
摘要:Given two 32 bit numbers, N and M, and two bit positions, i and j. Write a method to set all bits between i and j in N equal to M (e g , M becomes a ... 阅读全文
posted @ 2015-09-13 23:30 卖程序的小歪 阅读(393) 评论(0) 推荐(0)
摘要:Determine the number of bits required to flip if you want to convert integer n to integer m. Have you met this question in a real interview? Yes Exam... 阅读全文
posted @ 2015-09-13 22:46 卖程序的小歪 阅读(400) 评论(0) 推荐(0)
摘要:Given n pieces of wood with length L[i] (integer array). Cut them into small pieces to guarantee you could have equal or more than k pieces with the ... 阅读全文
posted @ 2015-09-13 12:23 卖程序的小歪 阅读(761) 评论(0) 推荐(0)
摘要:Implement int sqrt(int x). Compute and return the square root of x. Have you met this question in a real interview? Yes Example sqrt(3) = 1 sqrt(4) =... 阅读全文
posted @ 2015-09-12 23:22 卖程序的小歪 阅读(172) 评论(0) 推荐(0)
摘要:For a given sorted array (ascending order) and a target number, find the first index of this number in O(log n) time complexity. If the target number... 阅读全文
posted @ 2015-09-12 23:01 卖程序的小歪 阅读(119) 评论(0) 推荐(0)
摘要:Given an integer array, find a subarray with sum closest to zero. Return the indexes of the first number and last number. Have you met this question ... 阅读全文
posted @ 2015-09-12 22:29 卖程序的小歪 阅读(120) 评论(0) 推荐(0)
摘要:Given an array nums of integers and an int k, partition the array (i.e move the elements in "nums") such that:All elements < k are moved to the leftA... 阅读全文
posted @ 2015-09-12 00:51 卖程序的小歪 阅读(102) 评论(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 ... 阅读全文
posted @ 2015-09-12 00:17 卖程序的小歪 阅读(169) 评论(0) 推荐(0)
摘要:Given two strings, find the longest common substring. Return the length of it. Have you met this question in a real interview? Yes Example Given A = ... 阅读全文
posted @ 2015-09-11 23:14 卖程序的小歪 阅读(127) 评论(0) 推荐(0)
摘要:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. For example, given n = 12... 阅读全文
posted @ 2015-09-10 00:32 卖程序的小歪 阅读(166) 评论(0) 推荐(0)

1 2 3 4 5 ··· 16 下一页