kodeknight 947
View all
For a Given node of a binary tree, print the K distance nodes.
Find the distance between 2 nodes in Binary Tree
Find the distance between 2 nodes in Binary Tree
Program to count leaf nodes in a binary tree
Friend Circle - Hackerrank
Lazy Caterer's sequence
Lego Blocks Problem
K reverse a linked list with increasing K
Convert Binary Tree to Doubly linked list in level order
Doubly linked list ADT
Find the maximum distance covered using n bikes
Foldable Binary Trees - Given a binary tree, find out if the tree can be folded or not.
Given a node in binary tree - Check if left and right subtree are mirror of each other
Union and Intersection of two unsorted Linked Lists
Union and Intersection of two sorted arrays
Given two strings str1 and str2, write code to find out if all non-unique elements in str2 are in str1?
Algorithm Interview Questions - Set 1
Design Questions - Set 1
Given an array arr[], find the maximum j – i such that arr[j] > arr[i]
Given an array arr[], find the maximum j – i such that arr[j] > arr[i]
Finding IP Address from hostname in Windows Linux and Unix
Skiplist vs Binary tree
Skiplists
Max submatrix sum in a matrix
Find max subsquare whose border values are all 1
Transform one word into another by changing only one letter at a time
Search a long string for small strings in an array
Pattern Searching - Boyer Moore Algorithm – Bad Character Heuristic
Searching Patterns - Finite Automata
Rabin-Karp Algorithm
Suffix Array
Suffix tree
Longest word made of other words in an array
Find largest 1M numbers in 1B numbers
Shortest distances between two words in a file
Count the number of 2s between 0 and n
Randomly generate m integers from an array of size n
Find pairs of integers in an array that sum to a value
Implement rand7() using rand5()
Algorithm Analysis
Variables and Data Types Introduction
Encode XML
Find the frequency of a word in a book
Generate english phrase that describes a integer
Game of Master Mind
Find the maximum (or minimum) of two numbers (or morenumbers) without use of comparison operators or if-else
Number of trailing zeros in a factorial
Check if someone has won tic-tac-toe
Road Race
Sum of Hats
Coins on the Table
Coins on the Table
40 Pounds in the Balance
Crazy guy in Airplane
Monty hall problem - Choose the Correct Door
Cigars on Circular Table
Measure 45 minutes
Cards with Vowel & Even number
Wire Connections
OLD MONKS
Handshakes at Party
Key Exchange Puzzle
Russian Roulette
Cut a rectangular Cake
Rope Around EARTH
THE DEVIL & COLORED HATS
Black and white hats - Who knows what he is wearing
Prisoners and Boxes
Prisoner and lightbulb
Travelling MONK
Leap year Birthday
Crossing the BRIDGE past the GUARD
NEWYORK HAIR (Pigeonhole Principle)
Paying with RINGS
The MISSING Servent
TRUTH OR LIES
Engineers & Managers
Worm Crawls
undefined
Given 9 Dots, draw 4 Lines without picking up pen
Putting numbers in 3X3 matrix - s.t. Rows OR columns or diagonals add till 15
Robots on a line
Brothers and sisters
Using 5,5,5,5,5 can you make 37 along with any arithmetic operation.
Make 3 3 7 7 equal to 24
Make 3 3 7 7 equal to 24
Cards in the Dark
Islanders with dotted forheads
Get the job puzzle
ATM Money Withdrawal Limit
Number the 8 boxes so that no consecutive numbers touch
Number the 8 boxes so that no consecutive numbers touch
Minimum Sips
Aeroplanes round the world
River, Soldiers & Boat and children
Measure weights in balance
Last ball of Red Balls & Blue Balls
Deck of cards - Pick the cards with same color
Honest Man and single Question
Elephant and Bananas
Why does mirror lies sometimes?
Average salary of n people in the room
Point inside a triangle or NOT
Triangle Formation
Find the average of n numbers
Fill a magic square of size n, n being odd
CTRL+A, CTRL+C, CTRL+V
CTRL+A, CTRL+C, CTRL+V
Guess the solution of selecting 4 balls from set of 4 different colors
Point inside a rectangle or not
Given a number x, less than 100. How will you generate true with probability x/100.
Given a number 123456789, two opearators + and *, value k , find all the such expressions that evaluates to the given value k
Form a circle from 3 points
How many time function gets called?
Polite Numbers - Calculate all the ways such that a number can be written as sum of 2 or more consecutive numbers
Find average of a stream of the numbers
Print all sequences of given length
Number of Subsets without consecutive elements
Maximum subset of Cuboid boxes that can fit into one another
REST vs RPC
A Needle in the Haystack
Match two board configurations of tic-tac-toe problem
Given a set of numbers [1-N]. Subsets such that the sum of numbers in the subset is a prime number.
Petrol Bunk in a Circle.
Get Sentence from raw text
Get Sentence from raw text
Count the number of digits in the number
Finding the next palindrome for the given number
Finding the next palindrome for the given number
Given the push and pop sequence on stack, verify if corresponding sequence is correct or not
Data structure and algorithm interview question for java programmers
Memory requirement of a program in java
Hash Functions
Symbol table data structure
Fit 1*2 dominos in 2*N strip
Atomicity and Atomic operations
Selection Algorithms
Deterministic Selection - Select the i th smallest element
Find kth largest element from a 2-d sorted array
Nut and Bolt Problem (OR Key and Lock Problem) - Matching Nuts and Bolts when nuts cannot be compared with nuts and bolts with bolts
Cracking the coding interview questions
Solve Towers of Hanoi using stack
Find the nearest numbers that have same number of 1s for an integer
Can two threads call a synchronized method and normal method at the same time?
Scheduling method calls in sequence
Thread safe and exception safe singleton design pattern
How to measure the time spent in a context switch
Suggest the selling time and buying time of a share based on stock price prediction
Maximum product sub-array
Set cover
Create the REV function from Swap
Is there multiply function in 8085 microprocessor
Stone thrown from the boat
Number of rectangles in MxN matrix.
Three children
Black Dog, Black-out and Driver Problem
Inhereting wealth from wise Sheikh
Book worm
Alarm clock with snooze interval of 9
The U2 riddle
Eggs on slanted roof
Eye color of bus driver
The missing dollar
What is special about the following sequence of numbers?
Get the matching pair out from 12 pair of black and white socks
Move one DIGIT
Find the longest oscillating subsequence
Find the appropriate data structure
Common routing protocol
Compare and contrast IPv4 and IPv6
What is a network/subnet mask
What happens after typing a URL into a browser
Trie Tutorial
Allocate a two dimensional array using one call of malloc in C
Aligned malloc in C
Device FIFO queue problem
Prevent reverse engineering of DLLs
How to make sure a process doesn’t access unauthorized part of stack
What happens after a user presses a key on the keyboard?
Direct memory access(DMA)
Branch Target buffer
Virtual memory, page fault and thrashing
How to swap two String variables in java without using a third variable
ER diagram for a database of company
ER diagram for a database of company
What is denormalization?
Count the number of calls of put() and get() for a map in Java
Object reflection in Java
final, finally and finalize in Java
Finally block and return statement
Private constructor in Java
Smart pointer in C++
Take a pointer to a Node structure as a parameter and return a complete copy of the passed-in data structure
Searching Questions
Find the duplicate element most number of times in array of 0 to n-1
Destructor in base class needed to be virtual in C++
“volatile” keyword in C (and Java)
Deep copy and shallow copy in C++
Find all the words of Length N which are produced by natural order
Virtual functions in C++
Compare and contrast a hash table vs. an STL map
Print the last K lines of a file using C++
How to detect duplicate documents in billions of urls
Design a database with terabytes of data that supports efficient range queries
Fizz Buzz
Fizz Buzz
Finding the celebrity group
The Celebrity Problem
How to avoid getting into infinite loops when designing a web crawler
Find duplicate elements in the array with 4KB memory only
Generate an integer which is not in a file with 4 billion integers, limited memory
Sorting 10 GB file of integer with limited ram.
How to test an ATM in a distributed banking system
How to test a pen
Load test a webpage without using any test tools
How to test a canMoveTo(int x, int y) method in a chess game
Find the mistake(s) in the code
Programming errors cause program crashes in different places every single time
Check if array contains duplicates
Find duplicates in the ranged array
Find the two repeating elements in ranged array
Find the two non-repeating elements in a ranged array of repeating elements
Find the kth number with prime factors 3, 5 and 7
Find a line which passes the most number of points
Find a line to cut two squares in half
Implement *, -, and / operators using only +
Determine whether two lines would intersect on a Cartesian plane
One shot or at least two shots in three games?
Three Gods - God of Truth, Lies and Chaos
Labour and work problem - 20 women replaced by a men and boy alternatively
Circus tower sorting problem
Searching in a sorted array of strings with empty strings
Sorting a 2GB file with one string per line
Sort an array of strings so that anagrams are next to each other
Merge two sorted arrays - One having big enough buffer to hold another
Eight Queen Puzzle (likewise N Queen)
Number of ways of representing n cents using quarters, dimes, nickels and pennies
Implement the “paint fill” function
Print all combinations of n balanced parentheses
LATIN SQUARE” and its implementation
Permutations of every subset of size K
All possible paths for a robot moving along a NxN grid
How many lockers are open after 100 passes of toggles
Two egg puzzle
Interval Search Tree
Segment trees VS Interval trees VS binary indexed trees VS range trees
Merge Overlapping Intervals
How long does it take to remove c ‘magical’ hats from n people
Remove duplicates from unsorted array
Number of unique elements in sorted array with repeated elements
Get 4qt of water using a 5qt jug and a 3qt jug
Covering a chess board with dominos
Sieve of Atkins
Algorithm to find out number of factors of a number
Program to print all prime factors of a given number
To find the list of primes till N
Sieve of Eratosthenes
Efficient ways to check if number is prime number
Given a series (2,3,4,5,6,8,9,10,12,15,...) where the elements are in multiple of 2,3 and 5. Find the nth element of this sequence
Check if 2 trees are iso-morphic
Check if any number exists in the list after removing them from particular positions in natural number progression
Swap odd and even bits in an integer
Avid TV watcher
Find missing integer in an array with only access to jth bit of element A[i]
Division without using *, / or % (Divide Two Integers)
Count total set bits in all numbers from 1 to n
Next Power of 2
Count number of bits to be flipped to convert A to B
Some useful resources
Explain ((n & (n-1)) == 0)
Print binary representation of a decimal number
Print binary representation of a decimal number
You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes Create an algorithm to decide if T2 is a subtree of T1
Print all paths in a binary tree which sum up to a value
Finding the biggest difference between sorted array values
Set all bits of a number in a range equal to another number
Add arithmetic operators to make 3 1 3 6 = 8 true
Find all pairs (x, y) in a sorted array so that x + y < z
Divide a number by 3 without using *, /, +, -, % operators
Add two numbers without using arithmetic operators
Divide a number by 3 without using any of operators (%,/,*)
Add 1 to a given number without arithmetic operators
Strings index
Unique Paths in 2D grid
Implement a stack using queue
Find Local Minimum in an unsorted array with unique elements
Find Local Minimum in an unsorted array with unique elements
Sorted Linked List to Balanced BST
Convert sorted array to Balanced BST
Implement a stack using 2 queues
Stack with find-min/find-max in O(1) time
Algorithm Introduction
Find the minimum and maximum in the array
Find Maximum Value in the unsorted array
Find kth largest in an Array
find out the largest and second largest number in an array
find out the largest and second largest number in an array
How to find max. and min. in array using minimum comparisons?
Determine if a small tree T2 is the subtree of a huge tree T1
Create linked lists of all the nodes at each depth for a BST
Find if there is a path between two vertices in a directed graph
Find if there is a path between two vertices in a directed graph
How to check whether a given number n belongs to fibanocii series?
Find next higher number using exact same digits
Stack of plates
Implementing 2 stacks in an array
Provide an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0
Rotate n * n matrix by 90 degrees
Rotate n * n matrix by 90 degrees
Determine if a string has all unique characters
Algorithm to find top 10 search terms in search engine
Find the k most frequent words from a file
Given a binary tree with extra field "next pointer" in node, populate the next pointer to the nodes inorder successor
Data Structure to Emulate LRU Cache
Print nodes at k distance from root
Find the time period with the maximum number of overlapping intervals
Given an array of 100,000 pixel color values and each of which is an integer in the range (0,255). Give sorting algorithm.
Insertion sort on linked list
Selection sort on linked list
Sort a linked list using bubble sort
Sort a linked list using quick sort
Bubble sort on double linked list
Sort a linked list using merge sort
What's the fastest algorithm for sorting a linked list?
Find increasing 3-tuple (sub-sequence)
Merge two arrays efficiently - one sorted, another unsorted
Sorting implementation in c
Red Black Tree vs AVL Tree vs B-Tree
Union Find
Bottom-up Merge Sort
Given an integer array of which both first half and second half are sorted. Write a function to merge the two parts to create one single sorted array in place [do not use any extra space].
Amazon Questions - Set 1
k-way merge - Merging k sorted arrays of n elements
Find the maximum repeating number in array where all the elements are in range 0 to k-1, k ∈ [0,N]
Finding the max repeated element in an array
Print letters followed by their frequency (Run Length Encoding)
Remove duplicate characters in a string
Find first non repeating character in a string
Reverse a c-style string
Eliminate the pairs (two same chars adjacent to each other) in string
Move the Spaces to Front of the String
Replace all spaces in a string with “%20″ in c-style string
How many possible ways the child can run up the ladder
Find row with maximum number of 1s in sorted matrix
Company specific interviews
Find Position of the only Set Bit
Checking if a bit is on or off without affecting other bits
Toggle a specified bit in a bit string without effecting other bits
Divide a number by a power of two using bit right shift
Multiply a number by a power of two using bit left shift
Find largest Binary Search Tree in a Binary Tree
Convert Binary tree to Binary Search Tree conversion in place
Write code to find nth largest number from a stream of numbers.
Given a stream of characters, find the kth non-repeated character at any given time.
Given a stream of characters, find the kth non-repeated character at any given time.
Find all the pythagorean triplets in an array of integer
3 sum problem
Maximum value in a Sliding Window
Container With Most Water
Arrays Index
Maximum weight independent set (WIS) graph problem using DP
Sequence Alignment using Dynamic Programming
Application of clustering
Minimum Spanning tree MST
Binary Tree Level-Order Traversal Using Depth First Search (DFS) [Not to USE BFS]
Binary Tree Post-Order Traversal - Recursive and Iterative Solution
Binary Tree In-Order Traversal - Recursive and Iterative Solution
Find the rank w.r.t K - Number of nodes with value less than K
Iterators - Allowing iteration over data structures (in java)
Generic data structures in java
Evaluating postfix expression using stack
Converting an Infix Expression to Postfix expression using a stack
Checking whether the paranthesis are balanced in the expression
Resizing Array implementation of stack
Introduction of Array
find four elements in array whose sum equal to a given number X
Balanced Binary Search Tree Index
AVL Tree Index
AVL Tree Index
BFS (Breadth first search) on Graph
DFS (Depth first search) for graph
Dijkstra's algorithm for equal weight edges using BFS
Deleting the element from the heap
Application of heap (in computer science)
Building of heap
Array Implementation of Heap
Array Implementation of Heap
Find Nth largest element in the rotated sorted array
Find Nth largest element in the rotated sorted array
Find the rotation count in rotated sorted array
Random Contraction Algorithm
Graph Representations
Cuts of Graphs
Integer Multiplication using Karatsuba algorithm
Red Black Tree Index
Data Type in Data Structure
Pathological Data Sets and Universal Hashing Motivation
Hash Tables
Given a dictionary of word - Group all words into set of anagrams of each other
Splay trees
Boyer Moore Algorithm
Sorting
Tower of Hanoi Problem
Implementing doubly linked list using single pointer
Rearranging linked list first odd next even numbers
GetMin and GetMax in BST
Binary tree - Types and Properties
Linear Search on Array
Randomized Algorithm
Bellman ford algorithm - One source shortest path
Strongly Connected Graph
Topological Sorting
Minimum Cut Problem
Closest Pair Algorithm
Randomized Selection : Selecting the i'th smallest element
Meaning behind Master Method
Master Method for Solving Recurrences
Strassen's Subcubic Matrix Multiplication Algorithm
Inversions
BFS and Undirected Connectivity
Dijkstra's Shortest Path Algorithm
Adjacency list represention of graph in Java
Graph Search Introduction
How do I check if a number is a palindrome?
How do I check if a number is a palindrome?
Operation time complexity for a LINKED LIST
Operation time complexity for an ARRAY
Time complexity - Omega of algorithms
Time complexity of algorithms - In particular Big Omega of algorithms
String Searching Algorithm - Knuth Morris Pratt or KMP Algorithm
Priority Queue
What is a non-linear datastructure?
What is a linear datastructure?
What is a sorting algorithm?
Insertion sort
Introduction to Heap
Selection Sort
What is Bucket Sort?
What is a Graph data structure?
Graph Traversal Methods
Find shortest path using Dijkstra's Algorithm
Hashing, Hash Data Structure and Hash Table
What is a Complete Binary Tree?
Binary tree traversal: Preorder, Inorder, Post-order, BFS, DFS, Level Order, zig zag order
Data Structure Introduction
About
Legal
Circular Stack
Red Black Tree – Insertion
Red Black Tree – Deletion
Bloom filters
AVL Tree : Deleting a node from AVL Tree
AVL Tree : Rotations
Bitonic Sort
Bidirectional Bubble Sort
Priority Queue based on Sorted Linked Lists
Sorting in Hungarian Way
How to rotate an array?
2 Sum Problem : Given an integer array and a number T, find all unique pairs of (a, b) whose sum is equal to T
2 Sum Problem : Given an integer array and a number T, find all unique pairs of (a, b) whose sum is equal to T
Printing "Hello World" to screen without using a single semicolon in C/C++
Printing "Hello World" to screen without using a single semicolon in C/C++
Construct a full binary tree from a pre-order list of marked nodes
Converting integers less than 100 to words
Find all subsets of a given set OR Find power set of a given set
Find all subsets of a given set OR Find power set of a given set
Turning a bit off without affecting other bits
Bit Manipulation Tips and Tricks
Removing a loop in a singly linked list
Finding an integer that repeats odd number of times in an array of positive integers
Maximum continuous sum subarray problem
Maximum continuous sum subarray problem
Andersson Trees
ArrayDeque + Stack Algorithms
Sorted Linear Hash Table
Search trees
AVL Trees : Inserting a new Item
Concurrent Skip List
Huffman Codes
Convert Binary tree to double linked list in inorder traversal
Find the First Duplicated Integer in an Array containing numbers from 1 to N Without Using Extra Memory
Find the First Duplicated Integer in an Array containing numbers from 1 to N Without Using Extra Memory
Sorting Array of Three Kinds or The Dutch National Flag Problem OR three color sort
Shuffle a deck of cards perfectly
Find Local Maximum of a Function Using Bisection Method
Least-Square Linear Regression of Data Using C++
Convert integers to roman numbers
Check If an Integer's Bit Representation Is a Palindrome
Convert Binary Tree to Double Linked List in Zig-Zag Order
Minimum Distance Between Two Elements in an Array
Difference Between Sums of Odd and Even Levels in Binary Trees
Find common nodes from two linked lists using recursion
Y – shaped Linked List. Algorithm to find the node of intersection of two lists.
Remove duplicates from an unsorted linked list
print the sum( inclusive of the root ) of sub-tree rooted at each node in in-order in Binary Tree
Print pascal's triangle
What does flattening list of items into tree means
B + tree
B-tree
BTree in java
Red Black tree
Heap Sort in java
Binary heap : Introduction
Heap : Removing the min element using BubbleDown
Heap : Inserting an element into a heap using BubbleUp
Convert array of positive numbers to sorted array
Implement Add,Subtract,Multiplication,Division Using Bit Manipulation
K – Reverse a linked list
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Searching the element in sorted infinite array of integers
Minimum number of coins to get particular amount, given multiple denomination
Get maximum sum from coins in a line
Find optimal number of jumps to reach last element
Max possible sum of non-consecutive elements
Max possible sum of non-consecutive elements
Maximum size square sub-matrix with all 1s
Find largest sub-matrix with all 1s (not necessarily square)
Maximum Area Rectangle in Histogram
Iterative or Non recursive Inorder traversal on tree
DFS (Depth First Search) on tree or graph
BFS (Breadth first search ) OR Level Order Traversal on tree
Check if 2 strings are rotated versions of each other
Syntax highlighter for blogs
Escape all % characters in a string; % is the escape character
Remove whitespace from a string in-place, in linear time
Remove whitespace from a string in-place, in linear time
Implementing strcpy
Implementing strcat
Implementing strcmp
Double Linked List Structure
First non repeating element in the array
Find anagrams in the array of Strings
Gold bar with 7 segments
Implementing a strstr() / indexOf function
Combination of all the possible characters in the string
Concatenate N strings with good optimization
Check if Tree is a Balanced Tree
Some Stack Question
Implement 3 stacks in 1 array
Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.
Find the minimum element in the rotated sorted sorted array
Find the minimum element in the rotated sorted sorted array
Search an element in the sorted rotated array
Reverse a String using bits
Pick a Random Byte
Three Switches and Three Blub Problem
Deleting a node from a singly linked link list
Link list ADT
Calculate length of the linked list that contains loop
Add 2 large numbers in the form of list, without reversing the linked lists
Sorting a very large file which cannot fit in memory
Stack DS to implement constant time Minimum element lookup
Print a Binary Tree in Zig Zag Level Order or spiral order
Finding the Start of a Loop in a Linked List
Finding the Start of a Loop in a Linked List
GitHub: Setup SSH - Permission denied public key error
Karp-Rabin algorithm
Given a 10 digit number,find the greatest continuous 4 digit number.
WAP to Find Number of Divisor & sum of All Proper Devisor of Number Efficiently
Find Diameter of Binary Tree
Find Diameter of Binary Tree
Flipping Coins on the table
How to reverse a stack in place ?
Reaching the door of Heaven
Random Selection from a Linked List
Use some Datastructure to get O(1) stack operations
Next Greater Element in an array
Next Greater Element in an array
Folding BSTs
Diameter of a Binary Tree
Remove Character From String1 which are present in String2
Longest increasing subsequence
Vertical Sum of a Binary Tree
Vertical Sum of a Binary Tree
Prove that number between twin primes is divided by 6
How can you properly devide the hotel charges?
Passengers and Random Seats in Airplane
Find whether a given number N is of the form 2^x + 2^y (^ means exponentiation, x and y are positive).
Find out the matching socks
Minimax (Minmax) Search
Find an element in matrix in which rows and columns are sorted
Find first occurrence of a string in another
Row consisting max continuous chain of 1’s in an n * n grid
Convert a Number (unknown base) to a Base 10 Number
Majority element in the array
encodeURIComponent and decodeURIComponent in Java
atoi() in Java
In-Place Character Array Compression
itoa() in Java
Trie Operations Complexity
Trie : Searching in Trie
Trie : Inserting in Trie
Implementing the TRIE ADT in java
Trie ADT
Globe Walker
Trains and Birds
Gold for 7 days of work
The Ant Collision Problem
Is Your Husband a Cheat?
50 trucks with payload
Camel and Banana
Red, Green and Yellow Balls - heavy and light
One duplicate , one missing element in an array
Given numbers from 1 to N+1, with number being from 1 and N and one of the number being repeatative. Find the repeating element.
Find the smallest window in a string containing all characters of another string
Deleting a node in singly linked list if it is less than any of the successor nodes
Deleting a node in singly linked list if it is less than any of the successor nodes
Duplicate removal in Binary Search Tree
Squeeze all multiple spaces in a string into one space
Given a binary tree, print the sum( inclusive of the root ) of sub-tree rooted at each node in in-order
Leveling sectors in a circle
To find the longest substring with unique characters in a given string
Reverse the words in a sentence in place
Check if singly linked list is Palindrome
Spiral printing of a two dimensional array
Sum of two long positive numbers (each represented by linked lists)
Given a binary tree, print the sum( inclusive of the root ) of sub-tree rooted at each node in in-order
k largest(or smallest) elements in an array
Advantage and disadvantage of datastructures
Median of 2 sorted arrays of equal size n
Median of 2 sorted arrays of equal size n
Find median of a linked list or a Tree
Find longest palindrome in a string.
Find longest palindrome in a string.
Compare two string literals
Anagram Checker–To check if 2 strings are anagrams
Anagram Checker–To check if 2 strings are anagrams
Find nth largest value in a BST
Find nth largest value in a BST
XML Sequence Delimiter
Counting sort
Sorting a Stack using push,pop,isEmpty and peek
Balanced Search tree
AVL tree : Introduction
Implement a Queue using two stacks
How to reverse a doubly linked list ?
All permutations of a string
All permutations of a string
What is a data structure?
Intersection of two sorted lists or 2 sorted arrays
Scrabble Algorithms
What is BST or Binary Search tree?
Program to check if two rectangle overlap or itntersect
Program to check if two rectangle overlap or itntersect
Sum , factorial
Given two sorted arrays of size m and n respectively (m >> n), how to merge them together?
Interview Questions on Binary Search tree
BST : Improving search by using sentinel
Nth node in inorder traversal
IsBST : Check whether the tree provided is BST or not
Count binary search trees–Given N nodes, how many structurally BST are possible?
Check whether binary tree are same or not?
Double the tree such that insert new duplicate node for each node using cpp
Given a BST, create a mirror of it.
Given Binary Tree and sum, give root to leaf path such that all nodes add to that sum
Print binary search tree in increasing order
Print binary search tree in increasing order
Find the minimum data value find in Binary Search tree (using cpp)
Compute Maximum Depth or Height of binary search tree
Getting the size of Binary Search Tree
Create Copy of a tree (cpp)
AA - tree implementation in java
Spatial indexing with Quadtrees and Hilbert Curves
Anagram Trees : Part 2
Anagram Trees
Secure permutations with block ciphers
BK-Treesal
Why is manhole cover circular?
Deleting a middle node from a single linked list when pointer to the previous node is not available
Array implementation of stack
Array implementation of stack
int atoi( char* pStr )
Reverse a String
The Circular Lake Monster Problem
Arrays tip : Ignoring the zeroth row
Enums in java
Modifying Java Variables (w.r.t c and c++)
Constructor in java 1
Common naming convention : Coding Style
Improving coding style into classes
Improving coding style into functions or methods
Java specific naming convention
Specific cases of naming enhancing naming style
Java and CPP - the differences and similarities
Types of constructors
The stack and the heap
Word Length Frequency
Taking input as string 1 - " C-String to Int "
Using stl sort
Enum in c++
Beginning with vi
Use the variable closer to its use
How to bound check arrays in cpp / c
File IO in c++ 1
Using == operator in better way in cpp
Orthogonality
Longest common substring revisited
Troubleshooting DNS servers
Cloud Computing and Virtualization
Virtualization
Storage virtualization
Network virtualization
Self reproducing program in C
zero sized allocation using malloc
return and exit from main: difference
Pointer cause decay, references do not.
References and Constants
How to create function polymorphism in C
C Strings
Writing a DLL in C++
C++ STL: Iterators and Containers
BWT (Burrows Wheeler Transform) Encoding Algorithm
Socket Programming In C
Memory Management Basics
Memory Management In C and C + +
Finding time of execution of code in c
Reducing the space for LCS lengths
Reading from file or Reading integers from file
‘exit’ was not declared in this scope
Comparison sort and Integer sorts
Hirschberg’s linear space algorithm in C++
Hirschberg's algorithm
Dynamic Programming Algorithm (DPA) for Edit-Distance
Dynamic Programming Practise Problem Set 3
Longest common substring problem
Dynamic Programming Practise Problem Set 2
Matrix chain multiplication
Dynamic Programming Practise Problem Set 1
Prim's Algorithm
Kruskal's Algorithm
Dynamic-Programming Algorithm for the Activity-Selection Problem
An Activity Selection Problem ( Greedy Approach)
Dijkstra's Algorithm (Shortest Path)
Dynamic-Programming Solution to the 0-1 Knapsack Problem
Find the nth Fibonacci number
Solve the Rat In A Maze problem using backtracking.
Representing the Solution Space
Balancing Scales
Backtracking Algorithms
Divide and Conquer
Optimal Substructure
Overlapping subproblems in Dynamic programming
Common characterstics in dynamic programming
Introduction to Dynamic programming
Types of algorithms
Important ds question
Longest common subsequence : Dynamic programming
GCD and LCM
External Sorting - How do you sort a million 32-bit integers in 2MB RAM?
maximum index of an array
Missing integers
print combinations
Trie examples
Scrabble algorithm
Permutations and Combinations of string
Tries
Find the distinct words from a text file
superstring
DFS and BFS on trees, with and without recurssion
Remove duplicates from the sorted array
print all word combinations from phone number
String matching
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Write a C Program to reverse a stack "in place" using recursion ?
You are given a datatype, say X in C. The requirement is to get the size of the datatype, without declaring a variable or a pointer variable of that type, And, of course without using sizeof operator !
What can be maximum memory that a process can have in 32-bit machine? What assigns a process this memory?
What should be done when an exception occurs in the constructor?
How do you know where the memory leaks when you have multiple files?
WAP to find the number containing all the digits (1-9, no 0) such that number till nth digit is divisible by n
wo teen women wali puzzle ka sol..
how to chk if a no. is integer or not.
print 1-100 no.swithout loop in c
Write a C program which when compiled and run, prints out a message indicating whether the compiler that it is compiled with, allows /* */ comments to nest.
Find the nth Ugly Number
Given a string s1 and a string s2, write a snippet to say whether s2 is a rotation of s1 using only one call to strstr routine? (eg given s1 = ABCD and s2 = CDAB, return true, given s1 = ABCD, and s2 = ACBD , return false)
Reverse a linked list
Remove duplicates from a sorted linked list
Insert nodes into a linked list in a sorted fashion
Return the nth node from the end of a linked list
Binary search on a linked list
C program to free the nodes of a linked list
Copy of a linked list
Compare two linked lists
Middle of a linked list
Basic functions of link list - Add and print
Function to add node to double link list
Detecting a loop in a linked list
Comparing floats
Solution - #104 Project Euler
Simplified IP Addressing
Write a recursive function that, given the number of distinct values, computes the number of structurally unique binary search trees that store values from 1.....N.
Some cardinals
Tree
BST - Index
Threaded binary tree
Construct a tree given its inorder and preorder traversal strings. Similarly construct a tree given its inorder and post order traversal strings.
Given an expression tree, evaluate the expression and obtain a paranthesized form of the expression.
First / Lowest common ancestor (LCA) of 2 node in binary tree
Pre Order traversal - Recursive and Iterative solution
Find the median in a continous stream of numbers
Circular Queue
Bubble sort
Stack implementation using linked list
Quick sort
Radix sort
Merge Sort
Fibonacci, triangular, square, cube, pentagon numbers
Array of 0 and 1, put 0's at even position and 1's at odd position
Anagram program implentation
Finding whether 2 arrays are intersecting
Convert integer into a binary number
Binary search on Array - Recursive and iterative
Euclid's Algorithm : GCD of 2 integers
Given an array of n integers from 1 to n with one integer repeated twice
Data Structures Interview Questions (Theoritical)
Basic Mathematics in Algorithms
Given a list of n numbers from 1 to n-1, with one of the numbers repeated. Devise a method to determine which number is repeated
Give a fast way to multiply a number by 7
Bresenham's circle algorithm
Line Drawing Algorithms
Routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all.
Reversing a number
To reverse the bits in an integer
Check if the 20th bit of a 32 bit integer is on or off?
Count bits set in an integer
c program without main
Basic Interview Questions on networking
Various Software model
Left most n digits divisible by n
math.h
Chain Cut Problem
CTS Aptitude Question paper(Yellow)
CTS Aptitude Question paper(Yellow)
CTS Aptitude Question paper(Yellow)
PSYCHOMETRY TEST
Learn some words
Ten Horses and Nine Stable Problem (Focus on word)
Questions on various topics
Verbal questions 2
Verbal questions - mixture of words
File Handling in c
Random number generation
General Utilities
Error handling
Random access functions
File handling in cpp
Using pointers to break into bytes
#ifdef & #endif
sizeof operator
Using pascal keyword
Ratio and proportion difficult questions
Ratio and proportion difficult questions
Problems on partnership
Time and Distance questions
Trains
Multiplication Tables
Find all sets of consecutive integers that add up to 1000.
The smallest no. such that if its rightmost digit is placed at its left end, the new number so formed is precisely 50% larger than the original no.
Sum of last digit = sum of rest digits
What is a void pointer? Why can't we perform arithmetic on a void * pointer?
Program to check if the stack grows up or down
How can we sum the digits of a given number in single statement?
To swap the two nibbles in a byte
What is a NULL pointer? How is it different from an unitialized pointer? How is a NULL pointer defined?
WAP to check whether string is palindrome
A program to print numbers from 1 to 100 without using loops
Code to check if an integer is a power of 2 or not in a single line
How does free works?
Pointer indirection with care
Given two strings A and B, how would you find out if the characters in B were a subset of the characters in A?
What's the difference between const char *p, char * const p and const char * const p?
Syntax in C
Access non const member varible inside a const member function
How to add two numbers without using the plus operator?
What are the common causes of pointer bugs?
What is the difference between malloc() and calloc()?
Convert the decimal number to any base (binary, hex, oct etc...)
C code to dynamically allocate one, two and three dimensional arrays (using malloc())
What is a dangling pointer? What are reference counters with respect to pointers?
To add two long positive numbers (each represented by linked lists in C)
How to find out if a machine is 32 bit or 64 bit?
Operator Precedence in C & CPP
What's Database Normalization ?
What's an RDBMS ?
Types of Databases
What is a Database?
Acronyms used in operating system
Going beyond range of datatype
Extern keyword
Using ## and # with define.
Return values of some functions in c
The preprocessor directives can be redefined anywhere in the program
Given a rectangular (cuboidal for the puritans) cake with a rectangular piece removed (any size or orientation), how would you cut the remainder of the cake into two equal halves with one straight cut of a knife ?
How does throwing and catching exceptions differ from using setjmp and longjmp?
What is the difference between goto and longjmp() and setjmp()?
Besides communication cost, what is the other source of inefficiency in RPC?
Given an eight-bit bitmap graphics file, devise an algorithm to convert the file into a two-bit ASCII approximation
Given the time, devise an algorithm to calculate the angle between the hour and minute hands of an analog clock
Efficient code for extracting unique elements from a sorted list of array
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal
Some macros
Using define without assigning value
To determine whether machine is Little-Endian and Big-Endian?
Calculate pow function
Swapping 2 variables using macro
Swap two number in place without temporary variables.
3n+1 problem
jelly beans
Pirates
sum it up
Palindrome years
Red marbles, blue marbles
Reverse a string - word by word
17 September Solutions
Create a copy of a tree
tree1.h fully updated
Deleting a node from a Binary Search Tree
Inorder successor OR Predecessor of BST node
Implementing BST in C ( header file )
Initialising arrays
Multi-dimensional arrays
String Class in cpp(Standard cpp strings)
Stack ADT
Miscellaneous cases with printf
Strings
Method Overriding
Access specification
Access in cpp classes
Escape characters and printf
I/O in c without printf and scanf.
C preprocessor
Complicated Declaration
Program string class
Pattern matching program using Brute Force Algorithm
Program to manage array of pointers to strings
Program with the use of array of pointers to strings
Program to manage a 2-D array of Characters
Making a String class in cpp
Program to multiply two polynomials
Program to Add two polynomials
Program for matrix operations like determinant, singular, etc.
Program to perform operations like addition, multiplicaton, etc. on matrix
Program to merge two 1-D arrays
Representing Arrays as a class in cpp
Why
crackingthecodinginterview 140
View all
Max submatrix sum in a matrix
Find max subsquare whose border values are all 1
Transform one word into another by changing only one letter at a time
Search a long string for small strings in an array
Longest word made of other words in an array
Find largest 1M numbers in 1B numbers
Shortest distances between two words in a file
Count the number of 2s between 0 and n
Randomly generate m integers from an array of size n
Find pairs of integers in an array that sum to a value
Implement rand7() using rand5()
Encode XML
Find the frequency of a word in a book
Generate english phrase that describes a integer
Game of Master Mind
Find the maximum (or minimum) of two numbers (or morenumbers) without use of comparison operators or if-else
Number of trailing zeros in a factorial
Check if someone has won tic-tac-toe
Cracking the coding interview questions
Solve Towers of Hanoi using stack
Find the nearest numbers that have same number of 1s for an integer
Can two threads call a synchronized method and normal method at the same time?
Scheduling method calls in sequence
Thread safe and exception safe singleton design pattern
How to measure the time spent in a context switch
Common routing protocol
Compare and contrast IPv4 and IPv6
What is a network/subnet mask
What happens after typing a URL into a browser
Allocate a two dimensional array using one call of malloc in C
Aligned malloc in C
Device FIFO queue problem
Prevent reverse engineering of DLLs
How to make sure a process doesn’t access unauthorized part of stack
What happens after a user presses a key on the keyboard?
Direct memory access(DMA)
Branch Target buffer
Virtual memory, page fault and thrashing
ER diagram for a database of company
ER diagram for a database of company
What is denormalization?
Count the number of calls of put() and get() for a map in Java
Object reflection in Java
final, finally and finalize in Java
Finally block and return statement
Private constructor in Java
Smart pointer in C++
Take a pointer to a Node structure as a parameter and return a complete copy of the passed-in data structure
Destructor in base class needed to be virtual in C++
“volatile” keyword in C (and Java)
Deep copy and shallow copy in C++
Virtual functions in C++
Compare and contrast a hash table vs. an STL map
Print the last K lines of a file using C++
How to detect duplicate documents in billions of urls
Design a database with terabytes of data that supports efficient range queries
How to avoid getting into infinite loops when designing a web crawler
Find duplicate elements in the array with 4KB memory only
Generate an integer which is not in a file with 4 billion integers, limited memory
How to test an ATM in a distributed banking system
How to test a pen
Load test a webpage without using any test tools
How to test a canMoveTo(int x, int y) method in a chess game
Find the mistake(s) in the code
Programming errors cause program crashes in different places every single time
Find the kth number with prime factors 3, 5 and 7
Find a line which passes the most number of points
Find a line to cut two squares in half
Implement *, -, and / operators using only +
Determine whether two lines would intersect on a Cartesian plane
One shot or at least two shots in three games?
Circus tower sorting problem
Searching in a sorted array of strings with empty strings
Sorting a 2GB file with one string per line
Sort an array of strings so that anagrams are next to each other
Merge two sorted arrays - One having big enough buffer to hold another
Eight Queen Puzzle (likewise N Queen)
Number of ways of representing n cents using quarters, dimes, nickels and pennies
Implement the “paint fill” function
Print all combinations of n balanced parentheses
All possible paths for a robot moving along a NxN grid
How many lockers are open after 100 passes of toggles
Two egg puzzle
How long does it take to remove c ‘magical’ hats from n people
Get 4qt of water using a 5qt jug and a 3qt jug
Covering a chess board with dominos
Swap odd and even bits in an integer
Find missing integer in an array with only access to jth bit of element A[i]
Count number of bits to be flipped to convert A to B
Explain ((n & (n-1)) == 0)
Print binary representation of a decimal number
Print binary representation of a decimal number
You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes Create an algorithm to decide if T2 is a subtree of T1
Print all paths in a binary tree which sum up to a value
Set all bits of a number in a range equal to another number
Add arithmetic operators to make 3 1 3 6 = 8 true
Add two numbers without using arithmetic operators
Convert sorted array to Balanced BST
Determine if a small tree T2 is the subtree of a huge tree T1
Create linked lists of all the nodes at each depth for a BST
Find if there is a path between two vertices in a directed graph
Find if there is a path between two vertices in a directed graph
Stack of plates
Provide an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0
Rotate n * n matrix by 90 degrees
Rotate n * n matrix by 90 degrees
Determine if a string has all unique characters
Remove duplicate characters in a string
Reverse a c-style string
Replace all spaces in a string with “%20″ in c-style string
3 sum problem
Find all subsets of a given set OR Find power set of a given set
Find all subsets of a given set OR Find power set of a given set
Maximum continuous sum subarray problem
Maximum continuous sum subarray problem
Shuffle a deck of cards perfectly
Remove duplicates from an unsorted linked list
Check if 2 strings are rotated versions of each other
Check if Tree is a Balanced Tree
Implement 3 stacks in 1 array
Search an element in the sorted rotated array
Stack DS to implement constant time Minimum element lookup
Finding the Start of a Loop in a Linked List
Finding the Start of a Loop in a Linked List
Find an element in matrix in which rows and columns are sorted
The Ant Collision Problem
Anagram Checker–To check if 2 strings are anagrams
Anagram Checker–To check if 2 strings are anagrams
Sorting a Stack using push,pop,isEmpty and peek
Implement a Queue using two stacks
All permutations of a string
All permutations of a string
Deleting a middle node from a single linked list when pointer to the previous node is not available
Find the nth Fibonacci number
Return the nth node from the end of a linked list
First / Lowest common ancestor (LCA) of 2 node in binary tree
Find the median in a continous stream of numbers
To add two long positive numbers (each represented by linked lists in C)
To determine whether machine is Little-Endian and Big-Endian?
Swap two number in place without temporary variables.
incomplete 107
View all
Friend Circle - Hackerrank
Lego Blocks Problem
Convert Binary Tree to Doubly linked list in level order
Number of steps required to convert string 1 to string2 when only bring character to first index operation is giving
Find the largest subarray with sum of 0 in the given array
Skiplists
Max submatrix sum in a matrix
Find max subsquare whose border values are all 1
Suffix Array
Game of Master Mind
Check if someone has won tic-tac-toe
Sum of Hats
Wire Connections
OLD MONKS
Handshakes at Party
THE DEVIL & COLORED HATS
Black and white hats - Who knows what he is wearing
Prisoners and Boxes
Using 5,5,5,5,5 can you make 37 along with any arithmetic operation.
Make 3 3 7 7 equal to 24
Make 3 3 7 7 equal to 24
Cards in the Dark
Number the 8 boxes so that no consecutive numbers touch
Number the 8 boxes so that no consecutive numbers touch
Deck of cards - Pick the cards with same color
Triangle Formation
CTRL+A, CTRL+C, CTRL+V
CTRL+A, CTRL+C, CTRL+V
Guess the solution of selecting 4 balls from set of 4 different colors
Given a number 123456789, two opearators + and *, value k , find all the such expressions that evaluates to the given value k
Maximum subset of Cuboid boxes that can fit into one another
Fit 1*2 dominos in 2*N strip
Selection Algorithms
Common routing protocol
Compare and contrast IPv4 and IPv6
What is a network/subnet mask
Virtual memory, page fault and thrashing
How to swap two String variables in java without using a third variable
Searching Questions
How to detect duplicate documents in billions of urls
Eight Queen Puzzle (likewise N Queen)
Algorithm to find top 10 search terms in search engine
Find increasing 3-tuple (sub-sequence)
Red Black Tree vs AVL Tree vs B-Tree
Union Find
Bottom-up Merge Sort
Given an integer array of which both first half and second half are sorted. Write a function to merge the two parts to create one single sorted array in place [do not use any extra space].
Amazon Questions - Set 1
Find largest Binary Search Tree in a Binary Tree
Convert Binary tree to Binary Search Tree conversion in place
Binary Tree Post-Order Traversal - Recursive and Iterative Solution
Binary Tree In-Order Traversal - Recursive and Iterative Solution
Iterators - Allowing iteration over data structures (in java)
Generic data structures in java
Random Contraction Algorithm
Graph Representations
Integer Multiplication using Karatsuba algorithm
Splay trees
Implementing doubly linked list using single pointer
Rearranging linked list first odd next even numbers
Linear Search on Array
Topological Sorting
Dijkstra's Shortest Path Algorithm
Graph Search Introduction
String Searching Algorithm - Knuth Morris Pratt or KMP Algorithm
What is Bucket Sort?
Binary tree traversal: Preorder, Inorder, Post-order, BFS, DFS, Level Order, zig zag order
Circular Stack
Red Black Tree – Insertion
Bloom filters
Bitonic Sort
Bidirectional Bubble Sort
Construct a full binary tree from a pre-order list of marked nodes
Andersson Trees
ArrayDeque + Stack Algorithms
Sorted Linear Hash Table
Search trees
Concurrent Skip List
Huffman Codes
Convert Binary tree to double linked list in inorder traversal
Find the First Duplicated Integer in an Array containing numbers from 1 to N Without Using Extra Memory
Find the First Duplicated Integer in an Array containing numbers from 1 to N Without Using Extra Memory
Sorting Array of Three Kinds or The Dutch National Flag Problem OR three color sort
Find Local Maximum of a Function Using Bisection Method
Least-Square Linear Regression of Data Using C++
B + tree
BTree in java
Heap Sort in java
K – Reverse a linked list
DFS (Depth First Search) on tree or graph
Link list ADT
Calculate length of the linked list that contains loop
Longest increasing subsequence
Reverse the words in a sentence in place
Median of 2 sorted arrays of equal size n
Median of 2 sorted arrays of equal size n
Program to check if two rectangle overlap or itntersect
Program to check if two rectangle overlap or itntersect
Count binary search trees–Given N nodes, how many structurally BST are possible?
Kruskal's Algorithm
Bubble sort
Merge Sort
Binary search on Array - Recursive and iterative
Routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all.
c program without main
WAP to check whether string is palindrome
Program to merge two 1-D arrays
array 81
View all
Maximum single sell profit from stock
Find the largest subarray with sum of 0 in the given array
Given an array arr[], find the maximum j – i such that arr[j] > arr[i]
Given an array arr[], find the maximum j – i such that arr[j] > arr[i]
Find the appropriate data structure
LATIN SQUARE” and its implementation
Merge Overlapping Intervals
Find Local Minimum in an unsorted array with unique elements
Find Local Minimum in an unsorted array with unique elements
How to find max. and min. in array using minimum comparisons?
Find increasing 3-tuple (sub-sequence)
Merge two arrays efficiently - one sorted, another unsorted
Given an integer array of which both first half and second half are sorted. Write a function to merge the two parts to create one single sorted array in place [do not use any extra space].
k-way merge - Merging k sorted arrays of n elements
Find the maximum repeating number in array where all the elements are in range 0 to k-1, k ∈ [0,N]
Finding the max repeated element in an array
3 sum problem
Introduction of Array
find four elements in array whose sum equal to a given number X
Array Implementation of Heap
Array Implementation of Heap
Find Nth largest element in the rotated sorted array
Find Nth largest element in the rotated sorted array
Find the rotation count in rotated sorted array
Linear Search on Array
Operation time complexity for an ARRAY
What is a linear datastructure?
Selection Sort
How to rotate an array?
2 Sum Problem : Given an integer array and a number T, find all unique pairs of (a, b) whose sum is equal to T
2 Sum Problem : Given an integer array and a number T, find all unique pairs of (a, b) whose sum is equal to T
Finding an integer that repeats odd number of times in an array of positive integers
Maximum continuous sum subarray problem
Maximum continuous sum subarray problem
Find the First Duplicated Integer in an Array containing numbers from 1 to N Without Using Extra Memory
Find the First Duplicated Integer in an Array containing numbers from 1 to N Without Using Extra Memory
Sorting Array of Three Kinds or The Dutch National Flag Problem OR three color sort
Shuffle a deck of cards perfectly
Minimum Distance Between Two Elements in an Array
Convert array of positive numbers to sorted array
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
First non repeating element in the array
Find anagrams in the array of Strings
Implement 3 stacks in 1 array
Find the minimum element in the rotated sorted sorted array
Find the minimum element in the rotated sorted sorted array
Search an element in the sorted rotated array
Next Greater Element in an array
Next Greater Element in an array
Majority element in the array
atoi() in Java
In-Place Character Array Compression
One duplicate , one missing element in an array
Given numbers from 1 to N+1, with number being from 1 and N and one of the number being repeatative. Find the repeating element.
Spiral printing of a two dimensional array
k largest(or smallest) elements in an array
Median of 2 sorted arrays of equal size n
Median of 2 sorted arrays of equal size n
Given two sorted arrays of size m and n respectively (m >> n), how to merge them together?
Array implementation of stack
Array implementation of stack
Arrays tip : Ignoring the zeroth row
How to bound check arrays in cpp / c
maximum index of an array
Remove duplicates from the sorted array
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Find the median in a continous stream of numbers
Bubble sort
Finding whether 2 arrays are intersecting
Given an array of n integers from 1 to n with one integer repeated twice
C code to dynamically allocate one, two and three dimensional arrays (using malloc())
Efficient code for extracting unique elements from a sorted list of array
Initialising arrays
Multi-dimensional arrays
Program to manage array of pointers to strings
Program with the use of array of pointers to strings
Program to manage a 2-D array of Characters
Program to merge two 1-D arrays
Representing Arrays as a class in cpp
algorithms 80
View all
Asymptotic Notation
Growth Rate - The Importance of Asymptotics
Algorithm Interview Questions - Set 1
Given an array arr[], find the maximum j – i such that arr[j] > arr[i]
Given an array arr[], find the maximum j – i such that arr[j] > arr[i]
Algorithm Analysis
Deterministic Selection - Select the i th smallest element
Finding the celebrity group
Find all pairs (x, y) in a sorted array so that x + y < z
Algorithm Introduction
Find next higher number using exact same digits
Maximum value in a Sliding Window
Closest Pair Algorithm
Randomized Selection : Selecting the i'th smallest element
Meaning behind Master Method
Master Method for Solving Recurrences
Strassen's Subcubic Matrix Multiplication Algorithm
Inversions
Time complexity - Omega of algorithms
Time complexity of algorithms - In particular Big Omega of algorithms
String Searching Algorithm - Knuth Morris Pratt or KMP Algorithm
Introduction to Heap
What is a Graph data structure?
Finding an integer that repeats odd number of times in an array of positive integers
Huffman Codes
Convert integers to roman numbers
Karp-Rabin algorithm
Find the smallest window in a string containing all characters of another string
Program to check if two rectangle overlap or itntersect
Program to check if two rectangle overlap or itntersect
Spatial indexing with Quadtrees and Hilbert Curves
Anagram Trees
Secure permutations with block ciphers
BK-Treesal
Reducing the space for LCS lengths
Hirschberg’s linear space algorithm in C++
Hirschberg's algorithm
Dynamic Programming Algorithm (DPA) for Edit-Distance
Dynamic Programming Practise Problem Set 3
Longest common substring problem
Dynamic Programming Practise Problem Set 2
Matrix chain multiplication
Dynamic Programming Practise Problem Set 1
Prim's Algorithm
Kruskal's Algorithm
Dynamic-Programming Algorithm for the Activity-Selection Problem
An Activity Selection Problem ( Greedy Approach)
Dijkstra's Algorithm (Shortest Path)
Dynamic-Programming Solution to the 0-1 Knapsack Problem
Find the nth Fibonacci number
Solve the Rat In A Maze problem using backtracking.
Representing the Solution Space
Balancing Scales
Backtracking Algorithms
Divide and Conquer
Optimal Substructure
Overlapping subproblems in Dynamic programming
Types of algorithms
Longest common subsequence : Dynamic programming
GCD and LCM
External Sorting - How do you sort a million 32-bit integers in 2MB RAM?
maximum index of an array
Missing integers
print combinations
Trie examples
Scrabble algorithm
Permutations and Combinations of string
Tries
Find the distinct words from a text file
superstring
DFS and BFS on trees, with and without recurssion
Remove duplicates from the sorted array
print all word combinations from phone number
String matching
Threaded binary tree
Find the median in a continous stream of numbers
Quick sort
Binary search on Array - Recursive and iterative
Given a list of n numbers from 1 to n-1, with one of the numbers repeated. Devise a method to determine which number is repeated
Efficient code for extracting unique elements from a sorted list of array
tree 65
View all
You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes Create an algorithm to decide if T2 is a subtree of T1
Minimum Spanning tree MST
AVL Tree Index
AVL Tree Index
Splay trees
Topological Sorting
Red Black Tree – Insertion
Red Black Tree – Deletion
AVL Tree : Deleting a node from AVL Tree
AVL Tree : Rotations
Andersson Trees
Search trees
AVL Trees : Inserting a new Item
Convert Binary tree to double linked list in inorder traversal
print the sum( inclusive of the root ) of sub-tree rooted at each node in in-order in Binary Tree
What does flattening list of items into tree means
B + tree
B-tree
BTree in java
Red Black tree
Iterative or Non recursive Inorder traversal on tree
DFS (Depth First Search) on tree or graph
BFS (Breadth first search ) OR Level Order Traversal on tree
Check if Tree is a Balanced Tree
Print a Binary Tree in Zig Zag Level Order or spiral order
Find Diameter of Binary Tree
Find Diameter of Binary Tree
Duplicate removal in Binary Search Tree
Given a binary tree, print the sum( inclusive of the root ) of sub-tree rooted at each node in in-order
Given a binary tree, print the sum( inclusive of the root ) of sub-tree rooted at each node in in-order
Find nth largest value in a BST
Find nth largest value in a BST
Balanced Search tree
AVL tree : Introduction
What is BST or Binary Search tree?
Interview Questions on Binary Search tree
BST : Improving search by using sentinel
Nth node in inorder traversal
IsBST : Check whether the tree provided is BST or not
Count binary search trees–Given N nodes, how many structurally BST are possible?
Check whether binary tree are same or not?
Double the tree such that insert new duplicate node for each node using cpp
Given a BST, create a mirror of it.
Given Binary Tree and sum, give root to leaf path such that all nodes add to that sum
Print binary search tree in increasing order
Print binary search tree in increasing order
Find the minimum data value find in Binary Search tree (using cpp)
Compute Maximum Depth or Height of binary search tree
Getting the size of Binary Search Tree
Create Copy of a tree (cpp)
AA - tree implementation in java
Anagram Trees : Part 2
DFS and BFS on trees, with and without recurssion
Some cardinals
Tree
BST - Index
Threaded binary tree
Construct a tree given its inorder and preorder traversal strings. Similarly construct a tree given its inorder and post order traversal strings.
Given an expression tree, evaluate the expression and obtain a paranthesized form of the expression.
First / Lowest common ancestor (LCA) of 2 node in binary tree
Pre Order traversal - Recursive and Iterative solution
tree1.h fully updated
Deleting a node from a Binary Search Tree
Inorder successor OR Predecessor of BST node
Implementing BST in C ( header file )
binary-search-tree 62
View all
Given a BST with 2 nodes swapped, fix it
Given a binary search tree with 2 nodes swapped find number of pairs not following BST properties
Given the post order array find if tree is BST
Sorted Linked List to Balanced BST
Convert sorted array to Balanced BST
Create linked lists of all the nodes at each depth for a BST
Binary Tree Level-Order Traversal Using Depth First Search (DFS) [Not to USE BFS]
Binary Tree Post-Order Traversal - Recursive and Iterative Solution
Find the rank w.r.t K - Number of nodes with value less than K
Balanced Binary Search Tree Index
GetMin and GetMax in BST
Binary tree - Types and Properties
What is a Complete Binary Tree?
Binary tree traversal: Preorder, Inorder, Post-order, BFS, DFS, Level Order, zig zag order
Construct a full binary tree from a pre-order list of marked nodes
Convert Binary tree to double linked list in inorder traversal
Convert Binary Tree to Double Linked List in Zig-Zag Order
Difference Between Sums of Odd and Even Levels in Binary Trees
print the sum( inclusive of the root ) of sub-tree rooted at each node in in-order in Binary Tree
What does flattening list of items into tree means
Red Black tree
Iterative or Non recursive Inorder traversal on tree
DFS (Depth First Search) on tree or graph
BFS (Breadth first search ) OR Level Order Traversal on tree
Check if Tree is a Balanced Tree
Print a Binary Tree in Zig Zag Level Order or spiral order
Find Diameter of Binary Tree
Find Diameter of Binary Tree
Vertical Sum of a Binary Tree
Vertical Sum of a Binary Tree
Duplicate removal in Binary Search Tree
Find nth largest value in a BST
Find nth largest value in a BST
What is BST or Binary Search tree?
Interview Questions on Binary Search tree
BST : Improving search by using sentinel
Nth node in inorder traversal
IsBST : Check whether the tree provided is BST or not
Count binary search trees–Given N nodes, how many structurally BST are possible?
Check whether binary tree are same or not?
Double the tree such that insert new duplicate node for each node using cpp
Given a BST, create a mirror of it.
Given Binary Tree and sum, give root to leaf path such that all nodes add to that sum
Print binary search tree in increasing order
Print binary search tree in increasing order
Find the minimum data value find in Binary Search tree (using cpp)
Compute Maximum Depth or Height of binary search tree
Getting the size of Binary Search Tree
Create Copy of a tree (cpp)
Important ds question
DFS and BFS on trees, with and without recurssion
BST - Index
Threaded binary tree
Construct a tree given its inorder and preorder traversal strings. Similarly construct a tree given its inorder and post order traversal strings.
Given an expression tree, evaluate the expression and obtain a paranthesized form of the expression.
First / Lowest common ancestor (LCA) of 2 node in binary tree
Pre Order traversal - Recursive and Iterative solution
Find the median in a continous stream of numbers
tree1.h fully updated
Deleting a node from a Binary Search Tree
Inorder successor OR Predecessor of BST node
Implementing BST in C ( header file )
bst 62
View all
Given a BST with 2 nodes swapped, fix it
Given a binary search tree with 2 nodes swapped find number of pairs not following BST properties
Given the post order array find if tree is BST
Sorted Linked List to Balanced BST
Convert sorted array to Balanced BST
Create linked lists of all the nodes at each depth for a BST
Binary Tree Level-Order Traversal Using Depth First Search (DFS) [Not to USE BFS]
Binary Tree Post-Order Traversal - Recursive and Iterative Solution
Find the rank w.r.t K - Number of nodes with value less than K
Balanced Binary Search Tree Index
GetMin and GetMax in BST
Binary tree - Types and Properties
What is a Complete Binary Tree?
Binary tree traversal: Preorder, Inorder, Post-order, BFS, DFS, Level Order, zig zag order
Construct a full binary tree from a pre-order list of marked nodes
Convert Binary tree to double linked list in inorder traversal
Convert Binary Tree to Double Linked List in Zig-Zag Order
Difference Between Sums of Odd and Even Levels in Binary Trees
print the sum( inclusive of the root ) of sub-tree rooted at each node in in-order in Binary Tree
What does flattening list of items into tree means
Red Black tree
Iterative or Non recursive Inorder traversal on tree
DFS (Depth First Search) on tree or graph
BFS (Breadth first search ) OR Level Order Traversal on tree
Check if Tree is a Balanced Tree
Print a Binary Tree in Zig Zag Level Order or spiral order
Find Diameter of Binary Tree
Find Diameter of Binary Tree
Vertical Sum of a Binary Tree
Vertical Sum of a Binary Tree
Duplicate removal in Binary Search Tree
Find nth largest value in a BST
Find nth largest value in a BST
What is BST or Binary Search tree?
Interview Questions on Binary Search tree
BST : Improving search by using sentinel
Nth node in inorder traversal
IsBST : Check whether the tree provided is BST or not
Count binary search trees–Given N nodes, how many structurally BST are possible?
Check whether binary tree are same or not?
Double the tree such that insert new duplicate node for each node using cpp
Given a BST, create a mirror of it.
Given Binary Tree and sum, give root to leaf path such that all nodes add to that sum
Print binary search tree in increasing order
Print binary search tree in increasing order
Find the minimum data value find in Binary Search tree (using cpp)
Compute Maximum Depth or Height of binary search tree
Getting the size of Binary Search Tree
Create Copy of a tree (cpp)
Important ds question
DFS and BFS on trees, with and without recurssion
BST - Index
Threaded binary tree
Construct a tree given its inorder and preorder traversal strings. Similarly construct a tree given its inorder and post order traversal strings.
Given an expression tree, evaluate the expression and obtain a paranthesized form of the expression.
First / Lowest common ancestor (LCA) of 2 node in binary tree
Pre Order traversal - Recursive and Iterative solution
Find the median in a continous stream of numbers
tree1.h fully updated
Deleting a node from a Binary Search Tree
Inorder successor OR Predecessor of BST node
Implementing BST in C ( header file )
string 62
View all
Convert String to ZigZag Bottom Up
Given two strings str1 and str2, write code to find out if all non-unique elements in str2 are in str1?
Given an array filled with char elements, find the max length of continuous white space
A Needle in the Haystack
Get Sentence from raw text
Get Sentence from raw text
Determine if a string has all unique characters
Print letters followed by their frequency (Run Length Encoding)
Remove duplicate characters in a string
Find first non repeating character in a string
Reverse a c-style string
Eliminate the pairs (two same chars adjacent to each other) in string
Move the Spaces to Front of the String
Replace all spaces in a string with “%20″ in c-style string
Given a dictionary of word - Group all words into set of anagrams of each other
Boyer Moore Algorithm
String Searching Algorithm - Knuth Morris Pratt or KMP Algorithm
Check if 2 strings are rotated versions of each other
Escape all % characters in a string; % is the escape character
Remove whitespace from a string in-place, in linear time
Remove whitespace from a string in-place, in linear time
Implementing strcpy
Implementing strcat
Implementing strcmp
First non repeating element in the array
Find anagrams in the array of Strings
Implementing a strstr() / indexOf function
Combination of all the possible characters in the string
Concatenate N strings with good optimization
Some Stack Question
Reverse a String using bits
Karp-Rabin algorithm
Find first occurrence of a string in another
atoi() in Java
itoa() in Java
Find the smallest window in a string containing all characters of another string
Squeeze all multiple spaces in a string into one space
To find the longest substring with unique characters in a given string
Reverse the words in a sentence in place
Check if singly linked list is Palindrome
Compare two string literals
Anagram Checker–To check if 2 strings are anagrams
Anagram Checker–To check if 2 strings are anagrams
All permutations of a string
All permutations of a string
Anagram Trees : Part 2
Secure permutations with block ciphers
Longest common substring revisited
C Strings
Reducing the space for LCS lengths
Hirschberg’s linear space algorithm in C++
Hirschberg's algorithm
Dynamic Programming Algorithm (DPA) for Edit-Distance
Longest common substring problem
Longest common subsequence : Dynamic programming
String matching
Given a string s1 and a string s2, write a snippet to say whether s2 is a rotation of s1 using only one call to strstr routine? (eg given s1 = ABCD and s2 = CDAB, return true, given s1 = ABCD, and s2 = ACBD , return false)
WAP to check whether string is palindrome
Given two strings A and B, how would you find out if the characters in B were a subset of the characters in A?
String Class in cpp(Standard cpp strings)
Miscellaneous cases with printf
Making a String class in cpp
sorting 53
View all
Given an array arr[], find the maximum j – i such that arr[j] > arr[i]
Given an array arr[], find the maximum j – i such that arr[j] > arr[i]
Deterministic Selection - Select the i th smallest element
Sorting 10 GB file of integer with limited ram.
Sorting a 2GB file with one string per line
Sort an array of strings so that anagrams are next to each other
Merge two sorted arrays - One having big enough buffer to hold another
Merge Overlapping Intervals
Given an array of 100,000 pixel color values and each of which is an integer in the range (0,255). Give sorting algorithm.
Insertion sort on linked list
Selection sort on linked list
Sort a linked list using bubble sort
Sort a linked list using quick sort
Bubble sort on double linked list
Sort a linked list using merge sort
What's the fastest algorithm for sorting a linked list?
Merge two arrays efficiently - one sorted, another unsorted
Sorting implementation in c
Bottom-up Merge Sort
k-way merge - Merging k sorted arrays of n elements
Sorting
Topological Sorting
Randomized Selection : Selecting the i'th smallest element
What is a sorting algorithm?
Insertion sort
Selection Sort
What is Bucket Sort?
Bitonic Sort
Bidirectional Bubble Sort
Priority Queue based on Sorted Linked Lists
Sorting in Hungarian Way
2 Sum Problem : Given an integer array and a number T, find all unique pairs of (a, b) whose sum is equal to T
2 Sum Problem : Given an integer array and a number T, find all unique pairs of (a, b) whose sum is equal to T
Sorted Linear Hash Table
Sorting Array of Three Kinds or The Dutch National Flag Problem OR three color sort
Heap Sort in java
Searching the element in sorted infinite array of integers
DFS (Depth First Search) on tree or graph
Sorting a very large file which cannot fit in memory
Counting sort
Sorting a Stack using push,pop,isEmpty and peek
Given two sorted arrays of size m and n respectively (m >> n), how to merge them together?
Using stl sort
Comparison sort and Integer sorts
Important ds question
External Sorting - How do you sort a million 32-bit integers in 2MB RAM?
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Remove duplicates from a sorted linked list
Bubble sort
Quick sort
Radix sort
Merge Sort
dp 52
View all
Lego Blocks Problem
Maximize the number of magical gems by passing through array of house
Number of steps required to convert string 1 to string2 when only bring character to first index operation is giving
Implement a function similar to diff command in linux
Maximum single sell profit from stock
Find the largest subarray with sum of 0 in the given array
Maximum subset of Cuboid boxes that can fit into one another
Given a set of numbers [1-N]. Subsets such that the sum of numbers in the subset is a prime number.
Petrol Bunk in a Circle.
Get Sentence from raw text
Get Sentence from raw text
Suggest the selling time and buying time of a share based on stock price prediction
Maximum product sub-array
Circus tower sorting problem
Print all combinations of n balanced parentheses
Two egg puzzle
Avid TV watcher
Maximum weight independent set (WIS) graph problem using DP
Bellman ford algorithm - One source shortest path
Maximum continuous sum subarray problem
Maximum continuous sum subarray problem
Huffman Codes
Print pascal's triangle
Convert array of positive numbers to sorted array
Minimum number of coins to get particular amount, given multiple denomination
Get maximum sum from coins in a line
Find optimal number of jumps to reach last element
Max possible sum of non-consecutive elements
Max possible sum of non-consecutive elements
Maximum size square sub-matrix with all 1s
Longest increasing subsequence
To find the longest substring with unique characters in a given string
Find longest palindrome in a string.
Find longest palindrome in a string.
Longest common substring revisited
Reducing the space for LCS lengths
Hirschberg’s linear space algorithm in C++
Hirschberg's algorithm
Dynamic Programming Algorithm (DPA) for Edit-Distance
Dynamic Programming Practise Problem Set 3
Longest common substring problem
Dynamic Programming Practise Problem Set 2
Matrix chain multiplication
Dynamic Programming Practise Problem Set 1
Dynamic-Programming Algorithm for the Activity-Selection Problem
Dynamic-Programming Solution to the 0-1 Knapsack Problem
Find the nth Fibonacci number
Optimal Substructure
Overlapping subproblems in Dynamic programming
Common characterstics in dynamic programming
Introduction to Dynamic programming
Longest common subsequence : Dynamic programming
dynamic-programming 52
View all
Lego Blocks Problem
Maximize the number of magical gems by passing through array of house
Number of steps required to convert string 1 to string2 when only bring character to first index operation is giving
Implement a function similar to diff command in linux
Maximum single sell profit from stock
Find the largest subarray with sum of 0 in the given array
Maximum subset of Cuboid boxes that can fit into one another
Given a set of numbers [1-N]. Subsets such that the sum of numbers in the subset is a prime number.
Petrol Bunk in a Circle.
Get Sentence from raw text
Get Sentence from raw text
Suggest the selling time and buying time of a share based on stock price prediction
Maximum product sub-array
Circus tower sorting problem
Print all combinations of n balanced parentheses
Two egg puzzle
Avid TV watcher
Maximum weight independent set (WIS) graph problem using DP
Bellman ford algorithm - One source shortest path
Maximum continuous sum subarray problem
Maximum continuous sum subarray problem
Huffman Codes
Print pascal's triangle
Convert array of positive numbers to sorted array
Minimum number of coins to get particular amount, given multiple denomination
Get maximum sum from coins in a line
Find optimal number of jumps to reach last element
Max possible sum of non-consecutive elements
Max possible sum of non-consecutive elements
Maximum size square sub-matrix with all 1s
Longest increasing subsequence
To find the longest substring with unique characters in a given string
Find longest palindrome in a string.
Find longest palindrome in a string.
Longest common substring revisited
Reducing the space for LCS lengths
Hirschberg’s linear space algorithm in C++
Hirschberg's algorithm
Dynamic Programming Algorithm (DPA) for Edit-Distance
Dynamic Programming Practise Problem Set 3
Longest common substring problem
Dynamic Programming Practise Problem Set 2
Matrix chain multiplication
Dynamic Programming Practise Problem Set 1
Dynamic-Programming Algorithm for the Activity-Selection Problem
Dynamic-Programming Solution to the 0-1 Knapsack Problem
Find the nth Fibonacci number
Optimal Substructure
Overlapping subproblems in Dynamic programming
Common characterstics in dynamic programming
Introduction to Dynamic programming
Longest common subsequence : Dynamic programming
data-structure 42
View all
Skiplists
Suffix Array
Skiplist - TOC
Symbol table data structure
Deterministic Selection - Select the i th smallest element
Find all pairs (x, y) in a sorted array so that x + y < z
Implement a stack using queue
Implement a stack using 2 queues
Algorithm Introduction
Find next higher number using exact same digits
Iterators - Allowing iteration over data structures (in java)
Evaluating postfix expression using stack
Array Implementation of Heap
Array Implementation of Heap
Cuts of Graphs
Data Type in Data Structure
Hash Tables
Closest Pair Algorithm
Randomized Selection : Selecting the i'th smallest element
Meaning behind Master Method
Master Method for Solving Recurrences
Strassen's Subcubic Matrix Multiplication Algorithm
Inversions
Operation time complexity for a LINKED LIST
Operation time complexity for an ARRAY
Time complexity - Omega of algorithms
Time complexity of algorithms - In particular Big Omega of algorithms
String Searching Algorithm - Knuth Morris Pratt or KMP Algorithm
Priority Queue
What is a non-linear datastructure?
What is a linear datastructure?
What is a sorting algorithm?
Introduction to Heap
Selection Sort
What is Bucket Sort?
What is a Graph data structure?
Graph Traversal Methods
What is a Complete Binary Tree?
Data Structure Introduction
Link list ADT
Bubble sort
Quick sort
cpp 41
View all
Smart pointer in C++
Take a pointer to a Node structure as a parameter and return a complete copy of the passed-in data structure
Destructor in base class needed to be virtual in C++
“volatile” keyword in C (and Java)
Deep copy and shallow copy in C++
Virtual functions in C++
Compare and contrast a hash table vs. an STL map
Print the last K lines of a file using C++
Selection Sort
Bloom filters
Printing "Hello World" to screen without using a single semicolon in C/C++
Printing "Hello World" to screen without using a single semicolon in C/C++
Squeeze all multiple spaces in a string into one space
Leveling sectors in a circle
What is BST or Binary Search tree?
Common naming convention : Coding Style
Java and CPP - the differences and similarities
Enum in c++
How to bound check arrays in cpp / c
File IO in c++ 1
Using == operator in better way in cpp
Pointer cause decay, references do not.
References and Constants
Writing a DLL in C++
C++ STL: Iterators and Containers
‘exit’ was not declared in this scope
how to chk if a no. is integer or not.
Bubble sort
Stack implementation using linked list
File handling in cpp
Operator Precedence in C & CPP
How does throwing and catching exceptions differ from using setjmp and longjmp?
Stack ADT
Miscellaneous cases with printf
Strings
Access in cpp classes
C preprocessor
Complicated Declaration
Making a String class in cpp
Program to Add two polynomials
Representing Arrays as a class in cpp
recursion 40
View all
Print all sequences of given length
Get Sentence from raw text
Get Sentence from raw text
The Celebrity Problem
Eight Queen Puzzle (likewise N Queen)
Number of ways of representing n cents using quarters, dimes, nickels and pennies
Implement the “paint fill” function
Print all combinations of n balanced parentheses
All possible paths for a robot moving along a NxN grid
Two egg puzzle
Unique Paths in 2D grid
How many possible ways the child can run up the ladder
Find Nth largest element in the rotated sorted array
Find Nth largest element in the rotated sorted array
Find the rotation count in rotated sorted array
Tower of Hanoi Problem
Strassen's Subcubic Matrix Multiplication Algorithm
Find all subsets of a given set OR Find power set of a given set
Find all subsets of a given set OR Find power set of a given set
print the sum( inclusive of the root ) of sub-tree rooted at each node in in-order in Binary Tree
Print pascal's triangle
BFS (Breadth first search ) OR Level Order Traversal on tree
Find the minimum element in the rotated sorted sorted array
Find the minimum element in the rotated sorted sorted array
Search an element in the sorted rotated array
Print a Binary Tree in Zig Zag Level Order or spiral order
XML Sequence Delimiter
All permutations of a string
All permutations of a string
Given a BST, create a mirror of it.
Getting the size of Binary Search Tree
Find the nth Fibonacci number
GCD and LCM
Merge Sort
Convert integer into a binary number
Binary search on Array - Recursive and iterative
Euclid's Algorithm : GCD of 2 integers
Reversing a number
How to add two numbers without using the plus operator?
Calculate pow function
bits 39
View all
Find the maximum (or minimum) of two numbers (or morenumbers) without use of comparison operators or if-else
Find the nearest numbers that have same number of 1s for an integer
Swap odd and even bits in an integer
Find missing integer in an array with only access to jth bit of element A[i]
Division without using *, / or % (Divide Two Integers)
Count total set bits in all numbers from 1 to n
Next Power of 2
Count number of bits to be flipped to convert A to B
Some useful resources
Explain ((n & (n-1)) == 0)
Print binary representation of a decimal number
Print binary representation of a decimal number
Set all bits of a number in a range equal to another number
Divide a number by 3 without using *, /, +, -, % operators
Add two numbers without using arithmetic operators
Divide a number by 3 without using any of operators (%,/,*)
Add 1 to a given number without arithmetic operators
Find Position of the only Set Bit
Checking if a bit is on or off without affecting other bits
Toggle a specified bit in a bit string without effecting other bits
Divide a number by a power of two using bit right shift
Multiply a number by a power of two using bit left shift
Turning a bit off without affecting other bits
Bit Manipulation Tips and Tricks
Finding an integer that repeats odd number of times in an array of positive integers
Check If an Integer's Bit Representation Is a Palindrome
Implement Add,Subtract,Multiplication,Division Using Bit Manipulation
Reverse a String using bits
Give a fast way to multiply a number by 7
To reverse the bits in an integer
Check if the 20th bit of a 32 bit integer is on or off?
Count bits set in an integer
Using pointers to break into bytes
To swap the two nibbles in a byte
Code to check if an integer is a power of 2 or not in a single line
How to add two numbers without using the plus operator?
How to find out if a machine is 32 bit or 64 bit?
To determine whether machine is Little-Endian and Big-Endian?
Swap two number in place without temporary variables.
java 37
View all
Data structure and algorithm interview question for java programmers
Memory requirement of a program in java
Count the number of calls of put() and get() for a map in Java
Object reflection in Java
final, finally and finalize in Java
Finally block and return statement
Private constructor in Java
“volatile” keyword in C (and Java)
Find the kth number with prime factors 3, 5 and 7
Determine whether two lines would intersect on a Cartesian plane
Number of unique elements in sorted array with repeated elements
Data Structure to Emulate LRU Cache
Iterators - Allowing iteration over data structures (in java)
Generic data structures in java
Adjacency list represention of graph in Java
Selection Sort
Search an element in the sorted rotated array
atoi() in Java
XML Sequence Delimiter
Counting sort
All permutations of a string
All permutations of a string
Program to check if two rectangle overlap or itntersect
Program to check if two rectangle overlap or itntersect
Array implementation of stack
Array implementation of stack
Enums in java
Modifying Java Variables (w.r.t c and c++)
Constructor in java 1
Common naming convention : Coding Style
Improving coding style into classes
Improving coding style into functions or methods
Java specific naming convention
Specific cases of naming enhancing naming style
Java and CPP - the differences and similarities
Bubble sort
Stack implementation using linked list
single-link-list 34
View all
K reverse a linked list with increasing K
Union and Intersection of two unsorted Linked Lists
Priority Queue based on Sorted Linked Lists
Removing a loop in a singly linked list
Concurrent Skip List
Find common nodes from two linked lists using recursion
Y – shaped Linked List. Algorithm to find the node of intersection of two lists.
Remove duplicates from an unsorted linked list
K – Reverse a linked list
Deleting a node from a singly linked link list
Link list ADT
Calculate length of the linked list that contains loop
Add 2 large numbers in the form of list, without reversing the linked lists
Finding the Start of a Loop in a Linked List
Finding the Start of a Loop in a Linked List
Deleting a node in singly linked list if it is less than any of the successor nodes
Deleting a node in singly linked list if it is less than any of the successor nodes
Check if singly linked list is Palindrome
Sum of two long positive numbers (each represented by linked lists)
Find median of a linked list or a Tree
Intersection of two sorted lists or 2 sorted arrays
Deleting a middle node from a single linked list when pointer to the previous node is not available
Reverse a linked list
Remove duplicates from a sorted linked list
Insert nodes into a linked list in a sorted fashion
Return the nth node from the end of a linked list
Binary search on a linked list
C program to free the nodes of a linked list
Copy of a linked list
Compare two linked lists
Middle of a linked list
Basic functions of link list - Add and print
Detecting a loop in a linked list
To add two long positive numbers (each represented by linked lists in C)
c 33
View all
“volatile” keyword in C (and Java)
Selection Sort
Using == operator in better way in cpp
Self reproducing program in C
zero sized allocation using malloc
return and exit from main: difference
How to create function polymorphism in C
C Strings
Finding time of execution of code in c
Bubble sort
Give a fast way to multiply a number by 7
Reversing a number
To reverse the bits in an integer
Check if the 20th bit of a 32 bit integer is on or off?
Count bits set in an integer
File Handling in c
Syntax in C
What is a dangling pointer? What are reference counters with respect to pointers?
How to find out if a machine is 32 bit or 64 bit?
Operator Precedence in C & CPP
Going beyond range of datatype
Extern keyword
Using ## and # with define.
Return values of some functions in c
The preprocessor directives can be redefined anywhere in the program
What is the difference between goto and longjmp() and setjmp()?
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal
Some macros
Using define without assigning value
Stack ADT
I/O in c without printf and scanf.
C preprocessor
Complicated Declaration
data-structures 33
View all
Priority Queue
Bloom filters
ArrayDeque + Stack Algorithms
Search trees
Some Stack Question
Advantage and disadvantage of datastructures
Sorting a Stack using push,pop,isEmpty and peek
What is a data structure?
C++ STL: Iterators and Containers
Important ds question
Tries
DFS and BFS on trees, with and without recurssion
Some cardinals
Tree
BST - Index
Construct a tree given its inorder and preorder traversal strings. Similarly construct a tree given its inorder and post order traversal strings.
Given an expression tree, evaluate the expression and obtain a paranthesized form of the expression.
First / Lowest common ancestor (LCA) of 2 node in binary tree
Pre Order traversal - Recursive and Iterative solution
Circular Queue
Bubble sort
Stack implementation using linked list
Radix sort
Merge Sort
Data Structures Interview Questions (Theoritical)
Given a list of n numbers from 1 to n-1, with one of the numbers repeated. Devise a method to determine which number is repeated
Efficient code for extracting unique elements from a sorted list of array
tree1.h fully updated
Deleting a node from a Binary Search Tree
Inorder successor OR Predecessor of BST node
Implementing BST in C ( header file )
Stack ADT
Representing Arrays as a class in cpp
ds 33
View all
Priority Queue
Bloom filters
ArrayDeque + Stack Algorithms
Search trees
Some Stack Question
Advantage and disadvantage of datastructures
Sorting a Stack using push,pop,isEmpty and peek
What is a data structure?
C++ STL: Iterators and Containers
Important ds question
Tries
DFS and BFS on trees, with and without recurssion
Some cardinals
Tree
BST - Index
Construct a tree given its inorder and preorder traversal strings. Similarly construct a tree given its inorder and post order traversal strings.
Given an expression tree, evaluate the expression and obtain a paranthesized form of the expression.
First / Lowest common ancestor (LCA) of 2 node in binary tree
Pre Order traversal - Recursive and Iterative solution
Circular Queue
Bubble sort
Stack implementation using linked list
Radix sort
Merge Sort
Data Structures Interview Questions (Theoritical)
Given a list of n numbers from 1 to n-1, with one of the numbers repeated. Devise a method to determine which number is repeated
Efficient code for extracting unique elements from a sorted list of array
tree1.h fully updated
Deleting a node from a Binary Search Tree
Inorder successor OR Predecessor of BST node
Implementing BST in C ( header file )
Stack ADT
Representing Arrays as a class in cpp
link-list 33
View all
K reverse a linked list with increasing K
Rearranging linked list first odd next even numbers
Concurrent Skip List
Find common nodes from two linked lists using recursion
Y – shaped Linked List. Algorithm to find the node of intersection of two lists.
Remove duplicates from an unsorted linked list
K – Reverse a linked list
Deleting a node from a singly linked link list
Link list ADT
Calculate length of the linked list that contains loop
Add 2 large numbers in the form of list, without reversing the linked lists
Finding the Start of a Loop in a Linked List
Finding the Start of a Loop in a Linked List
Deleting a node in singly linked list if it is less than any of the successor nodes
Deleting a node in singly linked list if it is less than any of the successor nodes
Check if singly linked list is Palindrome
Sum of two long positive numbers (each represented by linked lists)
Find median of a linked list or a Tree
Intersection of two sorted lists or 2 sorted arrays
Deleting a middle node from a single linked list when pointer to the previous node is not available
Reverse a linked list
Remove duplicates from a sorted linked list
Insert nodes into a linked list in a sorted fashion
Return the nth node from the end of a linked list
Binary search on a linked list
C program to free the nodes of a linked list
Copy of a linked list
Compare two linked lists
Middle of a linked list
Basic functions of link list - Add and print
Detecting a loop in a linked list
Stack implementation using linked list
To add two long positive numbers (each represented by linked lists in C)
stack 33
View all
Given the push and pop sequence on stack, verify if corresponding sequence is correct or not
Solve Towers of Hanoi using stack
The Celebrity Problem
Implement a stack using queue
Implement a stack using 2 queues
Stack with find-min/find-max in O(1) time
Stack of plates
Implementing 2 stacks in an array
Maximum value in a Sliding Window
Generic data structures in java
Evaluating postfix expression using stack
Converting an Infix Expression to Postfix expression using a stack
Checking whether the paranthesis are balanced in the expression
Resizing Array implementation of stack
Circular Stack
ArrayDeque + Stack Algorithms
Maximum Area Rectangle in Histogram
Some Stack Question
Implement 3 stacks in 1 array
Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.
Add 2 large numbers in the form of list, without reversing the linked lists
Stack DS to implement constant time Minimum element lookup
How to reverse a stack in place ?
Use some Datastructure to get O(1) stack operations
Sorting a Stack using push,pop,isEmpty and peek
Implement a Queue using two stacks
Array implementation of stack
Array implementation of stack
The stack and the heap
Write a C Program to reverse a stack "in place" using recursion ?
Stack implementation using linked list
Program to check if the stack grows up or down
Stack ADT
duplicate 26
View all
Searching Questions
Find the duplicate element most number of times in array of 0 to n-1
Find duplicate elements in the array with 4KB memory only
Check if array contains duplicates
Find duplicates in the ranged array
Find the two repeating elements in ranged array
Find the two non-repeating elements in a ranged array of repeating elements
Remove duplicates from unsorted array
Number of unique elements in sorted array with repeated elements
Find the maximum repeating number in array where all the elements are in range 0 to k-1, k ∈ [0,N]
Finding the max repeated element in an array
Remove duplicate characters in a string
Find first non repeating character in a string
Finding an integer that repeats odd number of times in an array of positive integers
Find the First Duplicated Integer in an Array containing numbers from 1 to N Without Using Extra Memory
Find the First Duplicated Integer in an Array containing numbers from 1 to N Without Using Extra Memory
Remove duplicates from an unsorted linked list
First non repeating element in the array
Majority element in the array
One duplicate , one missing element in an array
Given numbers from 1 to N+1, with number being from 1 and N and one of the number being repeatative. Find the repeating element.
Duplicate removal in Binary Search Tree
Double the tree such that insert new duplicate node for each node using cpp
Remove duplicates from the sorted array
Remove duplicates from a sorted linked list
Given an array of n integers from 1 to n with one integer repeated twice
amazon 25
View all
Given a node in binary tree - Check if left and right subtree are mirror of each other
Given two strings str1 and str2, write code to find out if all non-unique elements in str2 are in str1?
Given a binary tree with extra field "next pointer" in node, populate the next pointer to the nodes inorder successor
Amazon Questions - Set 1
Replace all spaces in a string with “%20″ in c-style string
Find largest Binary Search Tree in a Binary Tree
Convert Binary tree to Binary Search Tree conversion in place
Write code to find nth largest number from a stream of numbers.
Given a stream of characters, find the kth non-repeated character at any given time.
Given a stream of characters, find the kth non-repeated character at any given time.
Find all the pythagorean triplets in an array of integer
Maximum value in a Sliding Window
Given a dictionary of word - Group all words into set of anagrams of each other
Rearranging linked list first odd next even numbers
K – Reverse a linked list
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Minimum number of coins to get particular amount, given multiple denomination
Search an element in the sorted rotated array
Longest increasing subsequence
Vertical Sum of a Binary Tree
Vertical Sum of a Binary Tree
Median of 2 sorted arrays of equal size n
Median of 2 sorted arrays of equal size n
Important ds question
interview 24
View all
Find Diameter of Binary Tree
Find Diameter of Binary Tree
Row consisting max continuous chain of 1’s in an n * n grid
Leveling sectors in a circle
Reverse the words in a sentence in place
Find nth largest value in a BST
Find nth largest value in a BST
Sorting a Stack using push,pop,isEmpty and peek
Interview Questions on Binary Search tree
Why is manhole cover circular?
Solve the Rat In A Maze problem using backtracking.
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Data Structures Interview Questions (Theoritical)
To reverse the bits in an integer
Check if the 20th bit of a 32 bit integer is on or off?
CTS Aptitude Question paper(Yellow)
CTS Aptitude Question paper(Yellow)
CTS Aptitude Question paper(Yellow)
Questions on various topics
Acronyms used in operating system
Besides communication cost, what is the other source of inefficiency in RPC?
Some macros
Using define without assigning value
graph 23
View all
Transform one word into another by changing only one letter at a time
The Celebrity Problem
Find if there is a path between two vertices in a directed graph
Find if there is a path between two vertices in a directed graph
Maximum weight independent set (WIS) graph problem using DP
BFS (Breadth first search) on Graph
DFS (Depth first search) for graph
Dijkstra's algorithm for equal weight edges using BFS
Random Contraction Algorithm
Graph Representations
Cuts of Graphs
Strongly Connected Graph
Topological Sorting
Minimum Cut Problem
BFS and Undirected Connectivity
Dijkstra's Shortest Path Algorithm
Adjacency list represention of graph in Java
Graph Search Introduction
What is a Graph data structure?
DFS (Depth First Search) on tree or graph
BFS (Breadth first search ) OR Level Order Traversal on tree
Prim's Algorithm
Kruskal's Algorithm
maths 23
View all
Point inside a triangle or NOT
Triangle Formation
Find the average of n numbers
Fill a magic square of size n, n being odd
CTRL+A, CTRL+C, CTRL+V
CTRL+A, CTRL+C, CTRL+V
Guess the solution of selecting 4 balls from set of 4 different colors
Point inside a rectangle or not
Given a number x, less than 100. How will you generate true with probability x/100.
Given a number 123456789, two opearators + and *, value k , find all the such expressions that evaluates to the given value k
Form a circle from 3 points
How many time function gets called?
Polite Numbers - Calculate all the ways such that a number can be written as sum of 2 or more consecutive numbers
Find average of a stream of the numbers
Print all sequences of given length
Number of Subsets without consecutive elements
Match two board configurations of tic-tac-toe problem
Find next higher number using exact same digits
Convert a Number (unknown base) to a Base 10 Number
Euclid's Algorithm : GCD of 2 integers
Bresenham's circle algorithm
Routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all.
Calculate pow function
balanced-trees 21
View all
Find the appropriate data structure
Convert sorted array to Balanced BST
Red Black Tree vs AVL Tree vs B-Tree
Balanced Binary Search Tree Index
AVL Tree Index
AVL Tree Index
Splay trees
Red Black Tree – Insertion
Red Black Tree – Deletion
AVL Tree : Deleting a node from AVL Tree
AVL Tree : Rotations
Andersson Trees
Search trees
AVL Trees : Inserting a new Item
B + tree
B-tree
BTree in java
Red Black tree
Check if Tree is a Balanced Tree
Balanced Search tree
AVL tree : Introduction
binary-tree 21
View all
For a Given node of a binary tree, print the K distance nodes.
Print all nodes that are at distance k from a leaf node
Find the distance between 2 nodes in Binary Tree
Find the distance between 2 nodes in Binary Tree
Program to count leaf nodes in a binary tree
Convert Binary Tree to Doubly linked list in level order
Foldable Binary Trees - Given a binary tree, find out if the tree can be folded or not.
Given a node in binary tree - Check if left and right subtree are mirror of each other
Check if 2 trees are iso-morphic
Print all paths in a binary tree which sum up to a value
Determine if a small tree T2 is the subtree of a huge tree T1
Given a binary tree with extra field "next pointer" in node, populate the next pointer to the nodes inorder successor
Print nodes at k distance from root
Binary Tree In-Order Traversal - Recursive and Iterative Solution
Binary tree - Types and Properties
What is a Complete Binary Tree?
Binary tree traversal: Preorder, Inorder, Post-order, BFS, DFS, Level Order, zig zag order
Print a Binary Tree in Zig Zag Level Order or spiral order
Vertical Sum of a Binary Tree
Vertical Sum of a Binary Tree
Balanced Search tree
bt 21
View all
For a Given node of a binary tree, print the K distance nodes.
Print all nodes that are at distance k from a leaf node
Find the distance between 2 nodes in Binary Tree
Find the distance between 2 nodes in Binary Tree
Program to count leaf nodes in a binary tree
Convert Binary Tree to Doubly linked list in level order
Foldable Binary Trees - Given a binary tree, find out if the tree can be folded or not.
Given a node in binary tree - Check if left and right subtree are mirror of each other
Check if 2 trees are iso-morphic
Print all paths in a binary tree which sum up to a value
Determine if a small tree T2 is the subtree of a huge tree T1
Given a binary tree with extra field "next pointer" in node, populate the next pointer to the nodes inorder successor
Print nodes at k distance from root
Binary Tree In-Order Traversal - Recursive and Iterative Solution
Binary tree - Types and Properties
What is a Complete Binary Tree?
Binary tree traversal: Preorder, Inorder, Post-order, BFS, DFS, Level Order, zig zag order
Print a Binary Tree in Zig Zag Level Order or spiral order
Vertical Sum of a Binary Tree
Vertical Sum of a Binary Tree
Balanced Search tree
search 21
View all
Searching Questions
Find the duplicate element most number of times in array of 0 to n-1
Check if array contains duplicates
Find duplicates in the ranged array
Find the two repeating elements in ranged array
Find the two non-repeating elements in a ranged array of repeating elements
Find Nth largest element in the rotated sorted array
Find Nth largest element in the rotated sorted array
Linear Search on Array
Finding an integer that repeats odd number of times in an array of positive integers
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Searching the element in sorted infinite array of integers
DFS (Depth First Search) on tree or graph
Find the minimum element in the rotated sorted sorted array
Find the minimum element in the rotated sorted sorted array
Trie : Searching in Trie
Balanced Search tree
BST : Improving search by using sentinel
BK-Treesal
Binary search on Array - Recursive and iterative
sorted-array 20
View all
Merge two sorted arrays - One having big enough buffer to hold another
Number of unique elements in sorted array with repeated elements
Finding the biggest difference between sorted array values
Sorted Linked List to Balanced BST
Convert sorted array to Balanced BST
Find the minimum and maximum in the array
Merge two arrays efficiently - one sorted, another unsorted
Given an integer array of which both first half and second half are sorted. Write a function to merge the two parts to create one single sorted array in place [do not use any extra space].
k-way merge - Merging k sorted arrays of n elements
Find Nth largest element in the rotated sorted array
Find Nth largest element in the rotated sorted array
Find the rotation count in rotated sorted array
Convert array of positive numbers to sorted array
Find the minimum element in the rotated sorted sorted array
Find the minimum element in the rotated sorted sorted array
Search an element in the sorted rotated array
Median of 2 sorted arrays of equal size n
Median of 2 sorted arrays of equal size n
Intersection of two sorted lists or 2 sorted arrays
Remove duplicates from the sorted array
interview-question 19
View all
Lazy Caterer's sequence
Given two strings str1 and str2, write code to find out if all non-unique elements in str2 are in str1?
Data structure and algorithm interview question for java programmers
Amazon Questions - Set 1
Finding an integer that repeats odd number of times in an array of positive integers
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Longest increasing subsequence
Vertical Sum of a Binary Tree
Vertical Sum of a Binary Tree
Majority element in the array
Spiral printing of a two dimensional array
All permutations of a string
All permutations of a string
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Given an array of n integers from 1 to n with one integer repeated twice
Routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all.
Given two strings A and B, how would you find out if the characters in B were a subset of the characters in A?
programming 19
View all
Bubble sort
Array of 0 and 1, put 0's at even position and 1's at odd position
Anagram program implentation
Finding whether 2 arrays are intersecting
Given an array of n integers from 1 to n with one integer repeated twice
Given a list of n numbers from 1 to n-1, with one of the numbers repeated. Devise a method to determine which number is repeated
Give a fast way to multiply a number by 7
Routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all.
c program without main
How can we sum the digits of a given number in single statement?
A program to print numbers from 1 to 100 without using loops
How to add two numbers without using the plus operator?
Convert the decimal number to any base (binary, hex, oct etc...)
How to find out if a machine is 32 bit or 64 bit?
Given an eight-bit bitmap graphics file, devise an algorithm to convert the file into a two-bit ASCII approximation
Given the time, devise an algorithm to calculate the angle between the hour and minute hands of an analog clock
Efficient code for extracting unique elements from a sorted list of array
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal
Swap two number in place without temporary variables.
conversion 18
View all
Convert Binary Tree to Doubly linked list in level order
Number of steps required to convert string 1 to string2 when only bring character to first index operation is giving
Sorted Linked List to Balanced BST
Convert sorted array to Balanced BST
Create linked lists of all the nodes at each depth for a BST
Convert Binary tree to Binary Search Tree conversion in place
Converting an Infix Expression to Postfix expression using a stack
Converting integers less than 100 to words
Convert Binary tree to double linked list in inorder traversal
Convert integers to roman numbers
Convert Binary Tree to Double Linked List in Zig-Zag Order
Convert array of positive numbers to sorted array
Convert a Number (unknown base) to a Base 10 Number
atoi() in Java
itoa() in Java
Taking input as string 1 - " C-String to Int "
Convert integer into a binary number
Convert the decimal number to any base (binary, hex, oct etc...)
min 18
View all
Shortest distances between two words in a file
Stack with find-min/find-max in O(1) time
Find the minimum and maximum in the array
Find Maximum Value in the unsorted array
Find kth largest in an Array
find out the largest and second largest number in an array
find out the largest and second largest number in an array
How to find max. and min. in array using minimum comparisons?
Find Nth largest element in the rotated sorted array
Find Nth largest element in the rotated sorted array
Find the rotation count in rotated sorted array
Minimum Distance Between Two Elements in an Array
Minimum number of coins to get particular amount, given multiple denomination
Find the minimum element in the rotated sorted sorted array
Find the minimum element in the rotated sorted sorted array
Stack DS to implement constant time Minimum element lookup
IsBST : Check whether the tree provided is BST or not
Find the minimum data value find in Binary Search tree (using cpp)
page 18
View all
Angular JS interview questions
Skiplist - TOC
Selection Algorithms
Cracking the coding interview questions
Trie Tutorial
Searching Questions
Some useful resources
Strings index
Find the minimum and maximum in the array
Sorting implementation in c
Company specific interviews
Arrays Index
Balanced Binary Search Tree Index
Red Black Tree Index
Sorting
Randomized Algorithm
Bit Manipulation Tips and Tricks
BST - Index
max 17
View all
Maximum single sell profit from stock
Given an array filled with char elements, find the max length of continuous white space
Finding the biggest difference between sorted array values
Stack with find-min/find-max in O(1) time
Find the minimum and maximum in the array
Find Maximum Value in the unsorted array
Find kth largest in an Array
find out the largest and second largest number in an array
find out the largest and second largest number in an array
How to find max. and min. in array using minimum comparisons?
Finding the max repeated element in an array
Maximum value in a Sliding Window
Maximum continuous sum subarray problem
Maximum continuous sum subarray problem
Majority element in the array
IsBST : Check whether the tree provided is BST or not
Compute Maximum Depth or Height of binary search tree
traversal 15
View all
Binary Tree Level-Order Traversal Using Depth First Search (DFS) [Not to USE BFS]
Binary tree traversal: Preorder, Inorder, Post-order, BFS, DFS, Level Order, zig zag order
Construct a full binary tree from a pre-order list of marked nodes
What does flattening list of items into tree means
Iterative or Non recursive Inorder traversal on tree
DFS (Depth First Search) on tree or graph
BFS (Breadth first search ) OR Level Order Traversal on tree
Given a binary tree, print the sum( inclusive of the root ) of sub-tree rooted at each node in in-order
Nth node in inorder traversal
Print binary search tree in increasing order
Print binary search tree in increasing order
DFS and BFS on trees, with and without recurssion
Construct a tree given its inorder and preorder traversal strings. Similarly construct a tree given its inorder and post order traversal strings.
Pre Order traversal - Recursive and Iterative solution
Implementing BST in C ( header file )
integer 14
View all
How do I check if a number is a palindrome?
How do I check if a number is a palindrome?
Convert integers to roman numbers
Convert a Number (unknown base) to a Base 10 Number
itoa() in Java
External Sorting - How do you sort a million 32-bit integers in 2MB RAM?
Missing integers
how to chk if a no. is integer or not.
Euclid's Algorithm : GCD of 2 integers
Given an array of n integers from 1 to n with one integer repeated twice
Check if the 20th bit of a 32 bit integer is on or off?
Count bits set in an integer
Find all sets of consecutive integers that add up to 1000.
Code to check if an integer is a power of 2 or not in a single line
time-complexity 14
View all
Resizing Array implementation of stack
DFS (Depth first search) for graph
Integer Multiplication using Karatsuba algorithm
Meaning behind Master Method
Master Method for Solving Recurrences
Dijkstra's Shortest Path Algorithm
Operation time complexity for a LINKED LIST
Operation time complexity for an ARRAY
Time complexity of algorithms - In particular Big Omega of algorithms
Heap Sort in java
Majority element in the array
Balanced Search tree
Quick sort
Basic Mathematics in Algorithms
binary-search 13
View all
Searching in a sorted array of strings with empty strings
Find Nth largest element in the rotated sorted array
Find Nth largest element in the rotated sorted array
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Searching the element in sorted infinite array of integers
Find the minimum element in the rotated sorted sorted array
Find the minimum element in the rotated sorted sorted array
Search an element in the sorted rotated array
Find an element in matrix in which rows and columns are sorted
Balanced Search tree
Intersection of two sorted lists or 2 sorted arrays
Binary search on Array - Recursive and iterative
count 13
View all
Given a binary search tree with 2 nodes swapped find number of pairs not following BST properties
Program to count leaf nodes in a binary tree
Count the number of 2s between 0 and n
Count the number of digits in the number
Count the number of calls of put() and get() for a map in Java
Number of unique elements in sorted array with repeated elements
Count total set bits in all numbers from 1 to n
Count number of bits to be flipped to convert A to B
Given an array of 100,000 pixel color values and each of which is an integer in the range (0,255). Give sorting algorithm.
Find the rotation count in rotated sorted array
Counting sort
Count binary search trees–Given N nodes, how many structurally BST are possible?
Count bits set in an integer
divide-and-conquer 13
View all
Maximum single sell profit from stock
Count the number of digits in the number
k-way merge - Merging k sorted arrays of n elements
Integer Multiplication using Karatsuba algorithm
Closest Pair Algorithm
Master Method for Solving Recurrences
Strassen's Subcubic Matrix Multiplication Algorithm
Median of 2 sorted arrays of equal size n
Median of 2 sorted arrays of equal size n
Divide and Conquer
Quick sort
Merge Sort
Binary search on Array - Recursive and iterative
inorder 13
View all
Given a BST with 2 nodes swapped, fix it
Given a binary search tree with 2 nodes swapped find number of pairs not following BST properties
Given a binary tree with extra field "next pointer" in node, populate the next pointer to the nodes inorder successor
Binary Tree In-Order Traversal - Recursive and Iterative Solution
Binary tree traversal: Preorder, Inorder, Post-order, BFS, DFS, Level Order, zig zag order
Given a binary tree, print the sum( inclusive of the root ) of sub-tree rooted at each node in in-order
Nth node in inorder traversal
Print binary search tree in increasing order
Print binary search tree in increasing order
Threaded binary tree
Construct a tree given its inorder and preorder traversal strings. Similarly construct a tree given its inorder and post order traversal strings.
Inorder successor OR Predecessor of BST node
Implementing BST in C ( header file )
merge 13
View all
Union and Intersection of two unsorted Linked Lists
Union and Intersection of two sorted arrays
Merge two sorted arrays - One having big enough buffer to hold another
Merge Overlapping Intervals
Sort a linked list using merge sort
What's the fastest algorithm for sorting a linked list?
Merge two arrays efficiently - one sorted, another unsorted
Bottom-up Merge Sort
Given an integer array of which both first half and second half are sorted. Write a function to merge the two parts to create one single sorted array in place [do not use any extra space].
k-way merge - Merging k sorted arrays of n elements
Given two sorted arrays of size m and n respectively (m >> n), how to merge them together?
Merge Sort
Program to merge two 1-D arrays
pointers 13
View all
Implementing doubly linked list using single pointer
Pointer cause decay, references do not.
References and Constants
Using pointers to break into bytes
What is a void pointer? Why can't we perform arithmetic on a void * pointer?
Program to check if the stack grows up or down
What is a NULL pointer? How is it different from an unitialized pointer? How is a NULL pointer defined?
How does free works?
Pointer indirection with care
What's the difference between const char *p, char * const p and const char * const p?
What are the common causes of pointer bugs?
C code to dynamically allocate one, two and three dimensional arrays (using malloc())
What is a dangling pointer? What are reference counters with respect to pointers?
puzzles 13
View all
Find the maximum distance covered using n bikes
Maximum number of chickens you cannot order
int atoi( char* pStr )
Reverse a String
The Circular Lake Monster Problem
Array of 0 and 1, put 0's at even position and 1's at odd position
Chain Cut Problem
jelly beans
Pirates
sum it up
Palindrome years
Red marbles, blue marbles
Reverse a string - word by word
reverse 13
View all
K reverse a linked list with increasing K
Reverse the doubly linked list
Rotate n * n matrix by 90 degrees
Rotate n * n matrix by 90 degrees
Reverse a c-style string
Check If an Integer's Bit Representation Is a Palindrome
K – Reverse a linked list
Reverse a String using bits
How to reverse a stack in place ?
Reverse the words in a sentence in place
How to reverse a doubly linked list ?
Write a C Program to reverse a stack "in place" using recursion ?
Reverse a linked list
understand 13
View all
Implement rand7() using rand5()
Monty hall problem - Choose the Correct Door
Key Exchange Puzzle
Russian Roulette
NEWYORK HAIR (Pigeonhole Principle)
undefined
Brothers and sisters
CTRL+A, CTRL+C, CTRL+V
CTRL+A, CTRL+C, CTRL+V
Match two board configurations of tic-tac-toe problem
Given a set of numbers [1-N]. Subsets such that the sum of numbers in the subset is a prime number.
Get Sentence from raw text
Get Sentence from raw text
arraysearch 12
View all
Find Nth largest element in the rotated sorted array
Find Nth largest element in the rotated sorted array
Find the rotation count in rotated sorted array
Linear Search on Array
Finding an integer that repeats odd number of times in an array of positive integers
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Searching the element in sorted infinite array of integers
Find the minimum element in the rotated sorted sorted array
Find the minimum element in the rotated sorted sorted array
Search an element in the sorted rotated array
Binary search on Array - Recursive and iterative
distance 12
View all
For a Given node of a binary tree, print the K distance nodes.
Print all nodes that are at distance k from a leaf node
Find the distance between 2 nodes in Binary Tree
Find the distance between 2 nodes in Binary Tree
Given an array arr[], find the maximum j – i such that arr[j] > arr[i]
Given an array arr[], find the maximum j – i such that arr[j] > arr[i]
Shortest distances between two words in a file
Minimum Distance Between Two Elements in an Array
Hirschberg’s linear space algorithm in C++
Hirschberg's algorithm
Dynamic Programming Algorithm (DPA) for Edit-Distance
Dijkstra's Algorithm (Shortest Path)
hard 12
View all
Max submatrix sum in a matrix
Find max subsquare whose border values are all 1
Transform one word into another by changing only one letter at a time
Search a long string for small strings in an array
Longest word made of other words in an array
Find largest 1M numbers in 1B numbers
Shortest distances between two words in a file
Count the number of 2s between 0 and n
Randomly generate m integers from an array of size n
Add two numbers without using arithmetic operators
Maximum Area Rectangle in Histogram
Find the median in a continous stream of numbers
linked-list 12
View all
Union and Intersection of two unsorted Linked Lists
Create linked lists of all the nodes at each depth for a BST
Insertion sort on linked list
Selection sort on linked list
Sort a linked list using bubble sort
Sort a linked list using quick sort
Sort a linked list using merge sort
What's the fastest algorithm for sorting a linked list?
Operation time complexity for a LINKED LIST
What is a non-linear datastructure?
Link list ADT
Stack implementation using linked list
backtracking 11
View all
Get Sentence from raw text
Get Sentence from raw text
Eight Queen Puzzle (likewise N Queen)
Print all combinations of n balanced parentheses
DFS (Depth First Search) on tree or graph
All permutations of a string
All permutations of a string
Solve the Rat In A Maze problem using backtracking.
Representing the Solution Space
Balancing Scales
Backtracking Algorithms
bfs 11
View all
Transform one word into another by changing only one letter at a time
Find if there is a path between two vertices in a directed graph
Find if there is a path between two vertices in a directed graph
Binary Tree Level-Order Traversal Using Depth First Search (DFS) [Not to USE BFS]
BFS (Breadth first search) on Graph
Dijkstra's algorithm for equal weight edges using BFS
BFS and Undirected Connectivity
Dijkstra's Shortest Path Algorithm
Graph Search Introduction
Graph Traversal Methods
BFS (Breadth first search ) OR Level Order Traversal on tree
dll 11
View all
Convert Binary Tree to Doubly linked list in level order
Reverse the doubly linked list
Doubly linked list ADT
Bubble sort on double linked list
Implementing doubly linked list using single pointer
Convert Binary Tree to Double Linked List in Zig-Zag Order
Double Linked List Structure
Vertical Sum of a Binary Tree
Vertical Sum of a Binary Tree
How to reverse a doubly linked list ?
Function to add node to double link list
doubly-linked-list 11
View all
Convert Binary Tree to Doubly linked list in level order
Reverse the doubly linked list
Doubly linked list ADT
Bubble sort on double linked list
Implementing doubly linked list using single pointer
Convert Binary Tree to Double Linked List in Zig-Zag Order
Double Linked List Structure
Vertical Sum of a Binary Tree
Vertical Sum of a Binary Tree
How to reverse a doubly linked list ?
Function to add node to double link list
graph-search 11
View all
Minimum Spanning tree MST
BFS (Breadth first search) on Graph
DFS (Depth first search) for graph
Dijkstra's algorithm for equal weight edges using BFS
Strongly Connected Graph
Topological Sorting
BFS and Undirected Connectivity
Dijkstra's Shortest Path Algorithm
Graph Search Introduction
DFS (Depth First Search) on tree or graph
BFS (Breadth first search ) OR Level Order Traversal on tree
heap 11
View all
Deleting the element from the heap
Application of heap (in computer science)
Building of heap
Array Implementation of Heap
Array Implementation of Heap
Dijkstra's Shortest Path Algorithm
Introduction to Heap
Heap Sort in java
Binary heap : Introduction
Heap : Removing the min element using BubbleDown
Heap : Inserting an element into a heap using BubbleUp
java-code 11
View all
Get Sentence from raw text
Get Sentence from raw text
Provide an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0
Determine if a string has all unique characters
Remove duplicate characters in a string
Replace all spaces in a string with “%20″ in c-style string
Check if 2 strings are rotated versions of each other
Finding the Start of a Loop in a Linked List
Finding the Start of a Loop in a Linked List
Anagram Checker–To check if 2 strings are anagrams
Anagram Checker–To check if 2 strings are anagrams
queue 11
View all
Queue ADT
Device FIFO queue problem
Implement a stack using queue
Implement a stack using 2 queues
Maximum value in a Sliding Window
BFS (Breadth first search) on Graph
Priority Queue
BFS (Breadth first search ) OR Level Order Traversal on tree
Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.
Implement a Queue using two stacks
Circular Queue
hashtable 10
View all
Hash Functions
find four elements in array whose sum equal to a given number X
Pathological Data Sets and Universal Hashing Motivation
Hash Tables
Bloom filters
2 Sum Problem : Given an integer array and a number T, find all unique pairs of (a, b) whose sum is equal to T
2 Sum Problem : Given an integer array and a number T, find all unique pairs of (a, b) whose sum is equal to T
Sorted Linear Hash Table
Vertical Sum of a Binary Tree
Vertical Sum of a Binary Tree
low-level 10
View all
Allocate a two dimensional array using one call of malloc in C
Aligned malloc in C
Device FIFO queue problem
Prevent reverse engineering of DLLs
How to make sure a process doesn’t access unauthorized part of stack
What happens after a user presses a key on the keyboard?
Direct memory access(DMA)
Branch Target buffer
Virtual memory, page fault and thrashing
To determine whether machine is Little-Endian and Big-Endian?
moderate 10
View all
Find pairs of integers in an array that sum to a value
Implement rand7() using rand5()
Encode XML
Find the frequency of a word in a book
Generate english phrase that describes a integer
Game of Master Mind
Find the maximum (or minimum) of two numbers (or morenumbers) without use of comparison operators or if-else
Maximum continuous sum subarray problem
Maximum continuous sum subarray problem
Swap two number in place without temporary variables.
networking 10
View all
Common routing protocol
Compare and contrast IPv4 and IPv6
What is a network/subnet mask
What happens after typing a URL into a browser
What is a Graph data structure?
Troubleshooting DNS servers
Socket Programming In C
Simplified IP Addressing
Basic Interview Questions on networking
Besides communication cost, what is the other source of inefficiency in RPC?
prime 10
View all
Fizz Buzz
Fizz Buzz
Sieve of Atkins
Algorithm to find out number of factors of a number
Program to print all prime factors of a given number
To find the list of primes till N
Sieve of Eratosthenes
Efficient ways to check if number is prime number
Prove that number between twin primes is divided by 6
Find the nth Ugly Number
programcpp 10
View all
Squeeze all multiple spaces in a string into one space
Word Length Frequency
Reading from file or Reading integers from file
Hirschberg’s linear space algorithm in C++
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Bubble sort
Quick sort
Radix sort
Merge Sort
unsorted-array 10
View all
Union and Intersection of two unsorted Linked Lists
Remove duplicates from unsorted array
Find Local Minimum in an unsorted array with unique elements
Find Local Minimum in an unsorted array with unique elements
Find the minimum and maximum in the array
Find Maximum Value in the unsorted array
Find kth largest in an Array
find out the largest and second largest number in an array
find out the largest and second largest number in an array
How to find max. and min. in array using minimum comparisons?
adobe 9
View all
Union and Intersection of two sorted arrays
How many time function gets called?
Create the REV function from Swap
Is there multiply function in 8085 microprocessor
Find all the words of Length N which are produced by natural order
Set all bits of a number in a range equal to another number
Median of 2 sorted arrays of equal size n
Median of 2 sorted arrays of equal size n
WAP to check whether string is palindrome
microsoft 9
View all
Point inside a triangle or NOT
Provide an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0
Given a dictionary of word - Group all words into set of anagrams of each other
K – Reverse a linked list
Globe Walker
Spiral printing of a two dimensional array
Median of 2 sorted arrays of equal size n
Median of 2 sorted arrays of equal size n
Important ds question
palindrome 9
View all
Finding the next palindrome for the given number
Finding the next palindrome for the given number
How do I check if a number is a palindrome?
How do I check if a number is a palindrome?
Check If an Integer's Bit Representation Is a Palindrome
Check if singly linked list is Palindrome
Find longest palindrome in a string.
Find longest palindrome in a string.
WAP to check whether string is palindrome
ranged-array 9
View all
Find the duplicate element most number of times in array of 0 to n-1
Check if array contains duplicates
Find duplicates in the ranged array
Find the two repeating elements in ranged array
Find the two non-repeating elements in a ranged array of repeating elements
Find the First Duplicated Integer in an Array containing numbers from 1 to N Without Using Extra Memory
Find the First Duplicated Integer in an Array containing numbers from 1 to N Without Using Extra Memory
Given numbers from 1 to N+1, with number being from 1 and N and one of the number being repeatative. Find the repeating element.
Given an array of n integers from 1 to n with one integer repeated twice
anagrams 8
View all
Sort an array of strings so that anagrams are next to each other
Given a dictionary of word - Group all words into set of anagrams of each other
Find anagrams in the array of Strings
Anagram Checker–To check if 2 strings are anagrams
Anagram Checker–To check if 2 strings are anagrams
Anagram Trees : Part 2
Anagram Trees
Anagram program implentation
integer-sort 8
View all
Given an array of 100,000 pixel color values and each of which is an integer in the range (0,255). Give sorting algorithm.
Finding an integer that repeats odd number of times in an array of positive integers
Sorting Array of Three Kinds or The Dutch National Flag Problem OR three color sort
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Counting sort
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
kth-largest 8
View all
Deterministic Selection - Select the i th smallest element
Find kth largest element from a 2-d sorted array
Find kth largest in an Array
Find Nth largest element in the rotated sorted array
Find Nth largest element in the rotated sorted array
Randomized Selection : Selecting the i'th smallest element
Find nth largest value in a BST
Find nth largest value in a BST
largest 8
View all
Deterministic Selection - Select the i th smallest element
Find kth largest element from a 2-d sorted array
Find kth largest in an Array
find out the largest and second largest number in an array
find out the largest and second largest number in an array
Randomized Selection : Selecting the i'th smallest element
Find nth largest value in a BST
Find nth largest value in a BST
matrix 8
View all
LATIN SQUARE” and its implementation
Provide an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0
Rotate n * n matrix by 90 degrees
Rotate n * n matrix by 90 degrees
Strassen's Subcubic Matrix Multiplication Algorithm
Maximum size square sub-matrix with all 1s
Spiral printing of a two dimensional array
Matrix chain multiplication
quicksort 8
View all
Nut and Bolt Problem (OR Key and Lock Problem) - Matching Nuts and Bolts when nuts cannot be compared with nuts and bolts with bolts
Sort a linked list using quick sort
What's the fastest algorithm for sorting a linked list?
Sorting
Sorting Array of Three Kinds or The Dutch National Flag Problem OR three color sort
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Quick sort
rotated-array 8
View all
Find Nth largest element in the rotated sorted array
Find Nth largest element in the rotated sorted array
Find the rotation count in rotated sorted array
How to rotate an array?
Check if 2 strings are rotated versions of each other
Find the minimum element in the rotated sorted sorted array
Find the minimum element in the rotated sorted sorted array
Search an element in the sorted rotated array
two-sorted-arrays 8
View all
Union and Intersection of two sorted arrays
Merge two sorted arrays - One having big enough buffer to hold another
Merge two arrays efficiently - one sorted, another unsorted
k-way merge - Merging k sorted arrays of n elements
Median of 2 sorted arrays of equal size n
Median of 2 sorted arrays of equal size n
Intersection of two sorted lists or 2 sorted arrays
Given two sorted arrays of size m and n respectively (m >> n), how to merge them together?
delete 7
View all
Remove whitespace from a string in-place, in linear time
Remove whitespace from a string in-place, in linear time
Deleting a node from a singly linked link list
Deleting a node in singly linked list if it is less than any of the successor nodes
Deleting a node in singly linked list if it is less than any of the successor nodes
Duplicate removal in Binary Search Tree
Deleting a node from a Binary Search Tree
dynamic-allocation 7
View all
Direct memory access(DMA)
zero sized allocation using malloc
Memory Management In C and C + +
Program to check if the stack grows up or down
What is a NULL pointer? How is it different from an unitialized pointer? How is a NULL pointer defined?
What is the difference between malloc() and calloc()?
C code to dynamically allocate one, two and three dimensional arrays (using malloc())
integer-array 7
View all
Maximum continuous sum subarray problem
Maximum continuous sum subarray problem
Find the First Duplicated Integer in an Array containing numbers from 1 to N Without Using Extra Memory
Find the First Duplicated Integer in an Array containing numbers from 1 to N Without Using Extra Memory
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Given an array of n integers from 1 to n with one integer repeated twice
limited-memory 7
View all
How to detect duplicate documents in billions of urls
Design a database with terabytes of data that supports efficient range queries
How to avoid getting into infinite loops when designing a web crawler
Find duplicate elements in the array with 4KB memory only
Generate an integer which is not in a file with 4 billion integers, limited memory
Sorting 10 GB file of integer with limited ram.
Sorting a 2GB file with one string per line
sorting-and-searching 7
View all
Circus tower sorting problem
Searching in a sorted array of strings with empty strings
Sorting a 2GB file with one string per line
Sort an array of strings so that anagrams are next to each other
Merge two sorted arrays - One having big enough buffer to hold another
Search an element in the sorted rotated array
Find an element in matrix in which rows and columns are sorted
two-arrays 7
View all
Merge two sorted arrays - One having big enough buffer to hold another
Merge two arrays efficiently - one sorted, another unsorted
Median of 2 sorted arrays of equal size n
Median of 2 sorted arrays of equal size n
Intersection of two sorted lists or 2 sorted arrays
Given two sorted arrays of size m and n respectively (m >> n), how to merge them together?
Finding whether 2 arrays are intersecting
zero 7
View all
Explain ((n & (n-1)) == 0)
Provide an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0
Sorting Array of Three Kinds or The Dutch National Flag Problem OR three color sort
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
2darray 6
View all
LATIN SQUARE” and its implementation
Unique Paths in 2D grid
Provide an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0
Find row with maximum number of 1s in sorted matrix
Find an element in matrix in which rows and columns are sorted
Spiral printing of a two dimensional array
binary-array 6
View all
Provide an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0
Sorting Array of Three Kinds or The Dutch National Flag Problem OR three color sort
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Find the point of transition from 0 to 1 in an infinite sorted array containings only 0 and 1 .
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
Sorting binary array - Array containing only 0 and 1 in one pass OR two color sort
inorder-traversal 6
View all
Given a binary search tree with 2 nodes swapped find number of pairs not following BST properties
Given a binary tree with extra field "next pointer" in node, populate the next pointer to the nodes inorder successor
Binary Tree In-Order Traversal - Recursive and Iterative Solution
Binary tree traversal: Preorder, Inorder, Post-order, BFS, DFS, Level Order, zig zag order
Threaded binary tree
Inorder successor OR Predecessor of BST node
unique 6
View all
Given two strings str1 and str2, write code to find out if all non-unique elements in str2 are in str1?
Determine if a string has all unique characters
2 Sum Problem : Given an integer array and a number T, find all unique pairs of (a, b) whose sum is equal to T
2 Sum Problem : Given an integer array and a number T, find all unique pairs of (a, b) whose sum is equal to T
First non repeating element in the array
To find the longest substring with unique characters in a given string
postorder 5
View all
Given the post order array find if tree is BST
Binary Tree Post-Order Traversal - Recursive and Iterative Solution
Binary tree traversal: Preorder, Inorder, Post-order, BFS, DFS, Level Order, zig zag order
Construct a tree given its inorder and preorder traversal strings. Similarly construct a tree given its inorder and post order traversal strings.
Implementing BST in C ( header file )
rectangle 5
View all
Find largest sub-matrix with all 1s (not necessarily square)
Maximum Area Rectangle in Histogram
Program to check if two rectangle overlap or itntersect
Program to check if two rectangle overlap or itntersect
Given a rectangular (cuboidal for the puritans) cake with a rectangular piece removed (any size or orientation), how would you cut the remainder of the cake into two equal halves with one straight cut of a knife ?
system-design-and-memory-limits 5
View all
How to detect duplicate documents in billions of urls
Design a database with terabytes of data that supports efficient range queries
How to avoid getting into infinite loops when designing a web crawler
Find duplicate elements in the array with 4KB memory only
Generate an integer which is not in a file with 4 billion integers, limited memory
preorder 4
View all
Binary tree traversal: Preorder, Inorder, Post-order, BFS, DFS, Level Order, zig zag order
Construct a full binary tree from a pre-order list of marked nodes
Construct a tree given its inorder and preorder traversal strings. Similarly construct a tree given its inorder and post order traversal strings.
Pre Order traversal - Recursive and Iterative solution
programming-questions 4
View all
Solve the Rat In A Maze problem using backtracking.
Write a C program which when compiled and run, prints out a message indicating whether the compiler that it is compiled with, allows /* */ comments to nest.
Find the nth Ugly Number
Given a string s1 and a string s2, write a snippet to say whether s2 is a rotation of s1 using only one call to strstr routine? (eg given s1 = ABCD and s2 = CDAB, return true, given s1 = ABCD, and s2 = ACBD , return false)
sum 4
View all
Find the largest subarray with sum of 0 in the given array
find four elements in array whose sum equal to a given number X
2 Sum Problem : Given an integer array and a number T, find all unique pairs of (a, b) whose sum is equal to T
2 Sum Problem : Given an integer array and a number T, find all unique pairs of (a, b) whose sum is equal to T