MO.AT

Mohit Athwani's

Adventures in C++, iOS, Unix, and the biggest of all..Life!.

Mohit Athwani

From India to California. In search of greener pastures. Writing about C++, Swift, algorithms and my life in general.

Read More

Posts

Get Random Node from Binary Search Tree

Algorithms, Binary Search Tree

Problem Statement

The goal of this challenge is to build your own BinarySearchTree class which in addition to supporting insert, find and delete also supports a special operation getRandomNode() which returns a random node from the binary search tree with special consideration that each node in the binary search tree is equally likely to be selected.

Read More

Check if a Tree is a sub tree of another

Algorithms, Tree, Graph, DFS

Problem Statement

There exists two very large binary trees, with one tree, T1 relatively much bigger than the other T2. How can we efficiently determine if T2 is a sub tree of T1?

Read More

Weaving two arrays

Algorithms, Backtracking, Recursion

This is an interesting recursion problem where the aim is to find all the possible weaves of 2 arrays keeping the relative order of the elements the same.

Read More

Taming Open Source Swift (SR-7292)

Open Source, Swift

In December 2015, Apple made Swift an open source language and made it available on Github. This piqued my interest, I dug around the code base for a little, cloned it and felt like I had achieved something great. Fast forward to Spring 2017, I made my first contribution to the swift-corelibs-foundation, two contributions to be precise. The way I made these contributions was by digging around the code base for the NSString class and implementing methods marked as NSUnimplemented(). With two accepted PRs to swift-corelibs-foundation, the next thing I did was opened up my resume and under the Key Projects section, added a new bullet point right on top – Currently contribute to Apple’s open source Swift project on Github.

Read More

Leetcode - 64. Minimum Path Sum

Algorithms, Array, Dynamic Programming

Problem Statement

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.

Read More

Generate Parantheses

Algorithms, Backtracking, Recursion, String, Leetcode

Before we start solving this problem, let’s do some math first. The problem statement clearly states that we have N pairs of parentheses to work with. That means for a string to be considered as part of the solution, it must be of size 2N.

Read More