Segmentation fault in solving maximum number of islands


this is my code it works fine for normal test cases but gives segmentation fault on submission