Please tell the approach>
?
Unable todo this question?
hi @mahroosanwar0901_2642b14836027bbf,
logic is same as i told above from one island group you need to go to another ,
suppose the size of island would have been 1 only (i.e 1 cell only) then the question becomes shortest path between 2 cell right? so u can use BFS directly.
But here the island group contains more than 1 cell so u r not able to visualize.
Consider whole thing as 1 group and first insert all the members in the queue ( for size 1 u just insert 1 cell but here insert all) now start doing BFS as soon as you reach the other group stop and return the steps you took
same has been implemented here https://ide.codingblocks.com/s/661183 ive commented the above logic here also do a dry run you’ll get it
where I am wrong?