1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
Task 1: "Number Combinations
You are given two integers $m and $n. Write a script print all possible
combinations of $n numbers from the list 1 2 3 ... $m.
Every combination should be sorted i.e. [2,3] is a valid combination but
[3,2] is not.
Example:
Input: $m = 5, $n = 2
Output: [ [1,2], [1,3], [1,4], [1,5], [2,3], [2,4], [2,5], [3,4], [3,5], [4,5] ]
"
My notes: generally I hate permutation questions, but this looks ok.
Task 2: "Letter Phone
You are given a digit string $S. Write a script to print all possible letter combinations that the given digit string could represent.
(1 represents _ or @,
2 A,B or C,
3 D,E or F,
4 G, H or I,
5 J, K or L,
6 M, M or O,
7 P, Q, R or S,
8 T, U or V,
9 W, X, Y or Z
letters from a phone panel)
Example:
Input: $S = '35'
Output: ["dj", "dk", "dl", "ej", "ek", "el", "fj", "fk", "fl"].
My notes: sounds pretty easy. Lookup the set of possibilities for each
letter, then cross-product them.
|