c - Given 2D array with marked cells, find duplicate shapes formed by those marked cells -
given 2d array cells marked , combined forms different linear shapes, how identify duplicate shapes.
0010000100000000000000000000
0010000100000000000000000000
0011100100000100000000011100
0000000100000111111000000000
0010000111100100000000000000
0110000000000001111000000000
0010000100000000000000000111
0000000001000000000011110000
0000000001111110000000000000
0010000001000000000000000000
here have 3 duplicate shapes :
1
111111
1
111
1
find shapes generated connected 1
s looping on cells until find 1
, use flood fill algorithm find shape formed connected cells. how store flood filled shape you, i'll assume created string representation of each one. find distinct strings using of jillions of methods out there comparing strings.
Comments
Post a Comment