摘要: According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insert 阅读全文
posted @ 2018-02-04 09:28 ZHUQW 阅读(128) 评论(0) 推荐(0) 编辑
摘要: Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making 阅读全文
posted @ 2018-02-03 14:14 ZHUQW 阅读(120) 评论(0) 推荐(0) 编辑
摘要: Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is "yes", if 6 is a decimal number and 110 is 阅读全文
posted @ 2018-02-03 11:53 ZHUQW 阅读(177) 评论(0) 推荐(0) 编辑
摘要: Given a sequence of positive integers and another positive integer p. The sequence is said to be a "perfect sequence" if M <= m * p where M and m are 阅读全文
posted @ 2018-02-03 09:20 ZHUQW 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 散列 1、需要模拟实现散列的情况 Liner Probing:对H(key)地址 + i 之后 mod Size 得新地址。 Quadratic probing: 对H(key)地址 + i^2 之后 mod Size 得新地址。 2、使用散列表 数字哈希:数组可直接使用。 map<key, val 阅读全文
posted @ 2018-02-03 00:03 ZHUQW 阅读(100) 评论(0) 推荐(0) 编辑
摘要: Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given {32, 321, 3214, 0229, 87}, we can 阅读全文
posted @ 2018-02-02 23:15 ZHUQW 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Given any permutation of the numbers {0, 1, 2,..., N-1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation tha 阅读全文
posted @ 2018-02-02 22:19 ZHUQW 阅读(223) 评论(0) 推荐(0) 编辑
摘要: The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a produc 阅读全文
posted @ 2018-02-02 20:41 ZHUQW 阅读(128) 评论(0) 推荐(0) 编辑
摘要: With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas s 阅读全文
posted @ 2018-02-02 17:58 ZHUQW 阅读(215) 评论(0) 推荐(0) 编辑
摘要: Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional 阅读全文
posted @ 2018-02-02 14:42 ZHUQW 阅读(115) 评论(0) 推荐(0) 编辑