Google Interview Report
- 1of 1 vote
AnswersCounting the islands.
- byPaco September 15, 2015 in United States
Given a map N x N, 2-D array
0 - sea
X - land
Land is connected by 4-Neighbor connections, i.e.: above, down, left and right.
00000000000000000000000000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
0000000000000000000X000000000000000
000000000000000000XXX00000000000000
000XX000000000000000000000000000000
000XXXX0000000000000000000000000000
0000000X000000000000000000000000000
00000000000000000000000000000000000
000000000000000000000X0000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
Output of this map: 4 (totally 4 islands on the map)| Report Duplicate | Flag | PURGE
Google iOS Developer - 2of 2 votes
AnswersNumber list compressing.
- byPaco September 15, 2015 in United States
Given an sorted array. Input: sorted number list
1, 2, 3,10, 25, 26, 30, 31, 32, 33
Output: find consecutive segments
print: 1-3, 10, 25-26, 30-33| Report Duplicate | Flag | PURGE
Google iOS Developer