Flip all zeros to ones

Given a string of bits and a number k. In one flip, you can toggle k consecutive characters, how many flips are required to change the entire string […]

Sum of all nodes at a vertical level

Given a binary tree and a number n representing the vertical level. Write code to compute the sum of all nodes which are at vertical […]

Vertical distance of a Node from root

Given a Binary Tree and a Node, Write a function that return the vertical distance of that node from root of the tree. The vertical […]

Max value node between two elements of BST

Given an array of integers that represent values of nodes in a Binary Search Tree. For example, If the given array is {9, 4, 17, […]

Check if a subtree exist with a given sum

Given a binary tree and a Number N, write code to check if there exist a subtree of the Binary tree with sum of all […]

Reversing a linked list iteratively using only 2 pointers

Given a linked list, write the non-recursive function to reverse the list. If Input list is 1 -> 2 -> 3 -> 4 -> 5 Then […]

How to prepare for Dynamic Programming Questions

The most difficult problems in Coding competitions and interviews of companies like Google, Microsoft etc. are from Dynamic Programming. DP as an approach to problem solving […]

Rotten Oranges Problem

Given a Matrix of order M*N, where each cell can have zero or one orange. The orange in the cell (if present) can be either […]

Recursive function to add 5 to alternate nodes of the linked list

Write a recursive function that add 5 to the alternate nodes of the linked list. For example, if the list is 1 -> 2 -> […]

Print a circular linked list

Write a function that prints all the elements of a circular linked list. (or traverse a circular linked list)