18.2 Write a method to shuffle a deck of cards. It must be a perfect shuffle—in other words, each of the 52! permutations of the deck has to be equall ...
分类:
其他好文 时间:
2016-05-03 01:55:01
阅读次数:
156
18.1 Write a function that adds two numbers. You should not use + or any arithmetic operators. 这道题让我们实现两数相加,但是不能用加号或者其他什么数学运算符号,那么我们只能回归计算机运算的本质,位操作Bi ...
分类:
其他好文 时间:
2016-05-02 10:26:30
阅读次数:
146
17.14 Oh, no! You have just completed a lengthy document when you have an unfortunate Find/Replace mishap. You have accidentally removed all spaces, p ...
分类:
其他好文 时间:
2016-04-30 12:47:05
阅读次数:
210
17.10 Since XML is very verbose, you are given a way of encoding it where each tag gets mapped to a pre-defined integer value. The language/grammar is ...
分类:
Web程序 时间:
2016-04-27 12:49:10
阅读次数:
184
17.9 Design a method to find the frequency of occurrences of any given word in a book. 这道题让我们找书中单词出现的频率,那么首先需要搞清楚的问题是,只需要统计一个单词,还是多个单词。如果是一个单词的话,那直接就遍 ...
分类:
其他好文 时间:
2016-04-26 11:01:01
阅读次数:
126
17.8 You are given an array of integers (both positive and negative). Find the contiguous sequence with the largest sum. Return the sum. LeetCode上的原题, ...
分类:
其他好文 时间:
2016-04-26 09:35:58
阅读次数:
163
17.6 Given an array of integers, write a method to find indices m and n such that if you sorted elements m through n, the entire array would be sorted ...
分类:
编程语言 时间:
2016-04-23 16:29:08
阅读次数:
160
17.2 Design an algorithm to figure out if someone has won a game oftic-tac-toe. 这道题让我们判断玩家是否能赢井字棋游戏,有下面几点需要考虑: 1. 判断是否能赢hasWon函数是调用一次还是多次,如果是多次,我们可能为了 ...
分类:
其他好文 时间:
2016-04-19 12:07:53
阅读次数:
272
17.1 Write a function to swap a number in place (that is, without temporary variables). 这道题让我们交换两个数,但是不能用额外空间,那么我们可以先做差值,存入a中,然后再加上b,存入b中,那么此时的b即为原来的a ...
分类:
其他好文 时间:
2016-04-18 06:24:17
阅读次数:
119
16.6 You are given a class with synchronized method A and a normal method B. If you have two threads in one instance of a program, can they both execu ...
分类:
其他好文 时间:
2016-04-17 13:16:51
阅读次数:
149