|
() @ - - | |
考了两道,附上原题:
第一题:Array Matrix
Write a function that determines whether a two dimensional array contains duplicate values within k indices of each other . 鐗涗汉浜戦泦,涓浜╀笁鍒嗗湴
The first line of input will be a number indicating how many rows are in the matrix. This will be followed by lines of input one for each row of the matrix each row will contain the same number of columns with each column separated by a space. Following the matrix will be a single line of input containing a number indicating the k value. .鏈枃鍘熷垱鑷1point3acres璁哄潧
Output should be ‘YES’ or ‘NO’ . 鐣欏鐢宠璁哄潧-涓浜╀笁鍒嗗湴
example:
4 -google 1point3acres
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
3
Output: No
. more info on 1point3acres.com
第二题:
Rotate Matrix
. From 1point 3acres bbs
Given a matrix, clockwise rotate elements in it.
Example:
Input
1 2 3
4 5 6
7 8 9
. 鐣欏鐢宠璁哄潧-涓浜╀笁鍒嗗湴
Output:. 1point3acres.com/bbs
4 1 2
7 5 3
8 9 6
For 4*4 matrix
Input:
1 2 3 4
5 6 7 8
9 10 11 12. 1point3acres.com/bbs
13 14 15 16
Output:
5 1 2 3.鏈枃鍘熷垱鑷1point3acres璁哄潧
9 10 6 4
13 11 7 8
14 15 16 12.1point3acres缃
时间两小时,第二题的testcase没有全部写完,感觉有点悬,老天保佑啊 |
评分
-
1
查看全部评分
-
|