## Insert Interval Leetcode Solution

The problem Insert Interval Leetcode Solution provides us with a list of some intervals and one separate interval. Then we are told to insert this new interval among the list of intervals. So, the new interval might be intersecting with intervals that are already in the list, or it might …

## Word Search Leetcode Solution

Problem Statement   Given an m x n board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where “adjacent” cells are horizontally or vertically neighbouring. The same letter cell may not be used more than once. Example …

## Search in Rotated Sorted Array Leetcode Solution

Consider a sorted array but one index was picked and the array was rotated at that point. Now, once the array has been rotated you are required to find a particular target element and return its index. In case, the element is not present, return -1. The problem is generally …

## An Interesting Method to generate Binary Numbers from 1 to n

Problem Statement   The problem “An Interesting Method to generate Binary Numbers from 1 to n” states that you are given a number n, print all the numbers from 1 to n in binary form. Examples   3 1 10 11   6 1 10 11 100 101 110 Algorithm   The generation …

## BST to a Tree with Sum of all Smaller Keys

In this problem we have given a Binary Search Tree, write an algorithm to convert best to a tree with sum of all smaller keys. Example   Input Output Pre-order : 19 7 1 54 34 88 Naive Approach   Traverse all the nodes one by one in any traversal form, and …

## Word Search

Word search is something like the word-finding puzzles at some time in our life. Today I bring to the table a modified crossword. My readers must be a bit perplexed as to what I am talking about. Without wasting any more time let us get to the problem statement Can …

## Smallest Element Repeated Exactly K Times

We are given an array A[] on size n. We have to find the smallest element that is repeated exactly k times in the array. Example   Input A[]= {1, 2 ,2 ,5 ,5 ,2 ,5} K=3 Output Smallest element with frequency K is: 2 Approach 1: Brute force   Main idea …

## Remove Minimum Number of Elements Such That no Common Element Exist in both Array

Given two arrays A and B consisting of n and m elements respectively. Remove minimum number of elements such that no common element exist in both array and print the count of elements which removed. Example   Input: A[]={ 1, 2, 1, 1} B[]= {1, 1} Output: Minimum elements to remove …

## Sorting a Queue without Extra Space

In sorting a queue without extra space problem we have given a queue, sort it using standard queue operations without extra space. Examples   Input queue = 10 -> 7 -> 2 -> 8 -> 6 Output queue = 2 -> 6 -> 7 -> 8 -> 10 Input queue = …

## Level order Traversal in Spiral Form

In this problem we have given a binary tree,  print its level order traversal in a spiral form. Examples   Input Output 10 30 20 40 50 80 70 60 Naive Approach for Level order Traversal in Spiral Form   The idea is to do a normal level order traversal using a …