# Category: Top Companies

## Colorful Numbers

Objective: Given a number, find out whether its colorful or not. Colorful Number: When in a given number, product of every digit of a sub-sequence are different. That number is called Colorful Number. See...

## Print All the Subsets of a Given Set (Power Set)

Objective: Given a set of numbers, print all the posssible subsets of it including empty set. Power Set: In mathematics, PowerSet of any given set S, PS(S) is set of all subsets of S...

## Goldbach’s Conjecture

Goldbach’s conjecture – Every even integer greater than 2 can be represented as the sum of two primes numbers. Example: Given Number : 200 Prime Numbers are 3 197 Prime Numbers are 7 193...

## Convert Decimal into Irreducible Fraction

Objective: Given a decimal number, convert it into irreducible fraction. Irreducible Fraction : An irreducible fraction is a fraction in which the numerator and denominator are integers that have no other common divisors than...

## Clock Angle Problem

Objective: Find the Angle between hour hand and minute hand at the given time. Example: Time : 12:45 Input : hour = 12, Minute = 45 Output : 112.5 Time : 3:30 Input :...

## Print All Combinations of subset of size K from Given Array

Objective: Given an array of integers of size N, print all the subsets of size k. (k<=N) Example: Generate all subsets of a fixed size k of a given set [1,2,3…n]. e.g, if n=5...

## Track the Maximum Element in a Stack.

Objective: In a Stack, keep track of maximum value in it. It might be the top element in the stack but once it is poped out, the maximum value should be from the rest...

## Print All Possible Valid Combinations Of Parenthesis of Given ‘N’

Objec­tive: – Given “n”, generate all valid parenthesis strings of length “2n”. Example: Given n=2 Output: (()) ()() Approach:

## Generate All Strings of n bits.

Objec­tive: – Generate All Strings of n bits, consider A[0..n-1] is an array of size n. Example : n = 3 Output: [0, 0, 0]    [1, 0, 0]    [0, 1, 0]    [1, 1, 0]...

## Implement Queue Using Stacks

Objective: We know that Queue is FIFO (First-in-First-Out) and Stack is LIFO ( Last-in-First-Out). Here our objective is to implement queue using stacks. Approach: Take 2 Stacks, stack1 and stack2. stack1 will be used...

## Alternate Splitting of a given Linked List

Objective: Given a singly linked list, split it into two linked lists. These linked lists will contain the alternate nodes from the given linked list. Example:

## Reverse The Doubly Linked List

Objective: Reverse The Doubly Linked List. Example: Approach: Every Node in a doubly linked list has next and previous pointer. Do the linear traversal of the linked list and keep swapping the next and...

## Swap Kth Node from the front with the Kth Node from the End

Objective: Given a Linked List and a number k, Swap Kth Node from the front with the Kth Node from the End Example: ->10->20->30->40->50->60->70 Swapping 1 Node from the Front and from the End...

## Print the Bottom View of the Binary Tree.

Objec­tive: – Given a binary tree, print it in Bottom View of it. What is Bottom View: Bottom view means when you look the tree from the bottom the nodes you will see will be...

## Delete X Nodes After Y Nodes In a Linked List

Objective: Given a Linked List and x and y. Delete x number of nodes after y nodes from the start. Example: ->10->20->30->40->50->60->70->80->90->100->110->120 Deleted 4 Nodes after 5 Nodes ->10->20->30->40->50->100->110->120 Approach: We need two pointers....