In this post, we have a look at using a queue and breath-first search algorithm to solve a Leetcode challenge. The problem is stated as follows. Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges...

## Asteroid Collision Solution – Leetcode coding challenge

The following asteroid collision problem is from Leetcode. The problem We are given an array asteroids of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed. Find out the state of the asteroids after all collisions. If two...