“Ringing in the New Year (2011→ 2012)” puzzle

Problem I am trying to solve the puzzle RINGING IN THE NEW YEAR. Start at 2011. By moving through the […]

Number of Islands in a 2d grid

Problem Recently, I’ve solved this “Number of Islands” problem on LeetCode, the solution was accepted by the LeetCode OJ. Problem […]

Run time complexity of printing a binary tree level by level

Problem I have some doubts about running time of following question. The problem is printing a binary tree level by […]

Finding shortest path in matrix

Problem Given an N x N matrix of positive integers, I need to find the shortest path from the first […]

Search for Tree

Problem Here is a search implementation for my tree. It searches each node in a breadth-first manner first, but it […]

LeetCode: N-ary Tree Level Order Traversal

Problem https://leetcode.com/problems/n-ary-tree-level-order-traversal/ Given an n-ary tree, return the level order traversal of its nodes’ values. (ie, from left to right, […]

Breadth First Search implementation in Python 3 to find path between two given nodes

Problem This is my Breadth First Search implementation in Python 3 that assumes cycles and finds and prints path from […]

Print BFS implementation in JavaScript

Problem Given a graph and a starting vertex print the value of each vertex in a breadth first order. Let’s […]

Optimising the BFS

Problem The input graph to the bfs function is in the form of edge list representation. from queue import deque […]

Leetcode: Find-bottom-left-tree-value

Problem https://leetcode.com/problems/find-bottom-left-tree-value/ Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input: […]