**Problem Statement:**

Given a 2d grid containing either values either 0 or 1 where 1 represents land and 0 represents water. You have to calculate the number of total islands in the given grid. An … Read More

Interview Questions asked in Google, Microsoft, Amazon

by Dhaval Dave

Given a 2d grid containing either values either 0 or 1 where 1 represents land and 0 represents water. You have to calculate the number of total islands in the given grid. An … Read More

by Dhaval Dave

Given a Binary Tree, print the diagonal traversal of the binary tree

Consider lines of slope -1 passing between nodes. Given a Binary Tree, print all diagonal elements in a binary tree belonging to same … Read More

by Dhaval Dave

Given a set T containing a list of integers and a sum S, does a subset of T exists whose sum is equal to S.

NOTE – Subset … Read More

by Dhaval Dave

Given an array of integers, find the nearest smaller number for every element such that the smaller element is on left side.

Examples:

Input: arr[] = {1, 6, 4, 10, 2, 5} Output: {-1, 1,… Read More

by Dhaval Dave

by Dhaval Dave

Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples … Read More

by Dhaval Dave

Set of Numbers are given to you.

convert them to Roman numbers.

Solution is in Hacker Earth style… Read More

by Dhaval Dave

With First look you think practical way of solving this question, and that is randomly taking a bolt and finding (by Looking at all nuts) perfect fit nut for it.

but does such logic to … Read More

by Dhaval Dave

Here We have implemented a Generic Stack Example with Templates in C++ where we can Push any element into stack.

#include <iostream>

#include <vector>

#include <cstdlib>

#include <string>

#include <stdexcept>

using namespace std;… Read More

by Dhaval Dave

/*

* usage: myTail [-n] [<filename>]
*/

#include <stdio.h> #include <stdlib.h> #define MAX_LINE_LEN 1024 #define DEFAULT_N 10 int main(int argc, char *argv[]) { char **tail; int count = DEFAULT_N, n, i, headX = 0, tailX… Read More