/InterviewRoom-JAVA-solutions

This is a repo for all the solutions of github repository InterviewRoom. The solutions are taken from all over the internet, and those are among the best complexity solutions by top coders from competitive programming field.

Primary LanguageJava

InterviewRoom-JAVA-solutions

This is a repo for all the solutions of ashuray's github repository InterviewRoom. The solutions are taken from all over the internet, and those are among the best complexity solutions by top coders from competitive programming field.

Code Structure

  • Solution : As many Competitive Programming platforms requires a function/method which returns some data, the codes in this repo also follow that same structure. Check // SOLUTION comments in every program, underneath which you will find the function/method for solving the given problem.
  • Input : As most Competitive Programming platforms requires a fuction which takes some input, not much of thought is given in taking input from the user/console while writing these programs. Check // INPUT : comments in every program, underneath which you will find the input data. You are free to implement any sort of console input strategies.
  • Output : The output of the given problem varies from question to question. The Output in these programs are written exactly same as in accordance to the given problem. Check // OUTPUT : comments in every program, underneath which you will find the output printed to the console. You are free to implement any sort of console output strategies as per the questions given.

Interview Preparation

You can crack any Interview if you are preparing yourself in a well organised manner. There are lots of Data Structure and Algorithm problems on internet and it is quite impossible for a person to practice all of them. So it is really important that you practice a list of few problems which are really important and covers almost every concepts.

I (ashuray) have tried my best to sort all those problems for you and ordered them as well. I hope if you follow my list and study in the same order in which i have given, it will surely help you prepare very well for the Job Interview in your 2 months vacation.

Table of Contents

Data Structures

Array

ID PROBLEM STATEMENT PROBLEM LINK SOLUTIONS
1 Missing number in array Leetcode , GFG Solution
2 Subarray with given sum GFG Solution
3 2 Sum LeetCode , InterviewBit, GFG , Solution
4 Majority Element LeetCode , InterviewBit , GFG Solution
5 Max Consecutive Ones LeetCode , InterviewBit Solution
6 Sort an array of 0s, 1s and 2s GFG , LeetCode Solution
7 Spiral Matrix LeetCode , InterviewBit Solution
8 Find the duplicate number LeetCode Solution
9 Largest number formed from an array LeetCode , InterviewBit, GFG Solution
10 Next Permutation LeetCode , InterviewBit Solution
11 Merge Overlapping Intervals LeetCode , InterviewBit Solution
12 First Missing Positive LeetCode , InterviewBit Solution

LinkedList

ID PROBLEM STATEMENT PROBLEM LINK SOLUTIONS
1 Find middle element in a linked list LeetCode , GFG Solution
2 Remove n'th node from end of a linked list LeetCode , InterviewBit Solution
3 Intersection Point in Y shaped linked list LeetCode , InterviewBit Solution
4 Reverse a linked list LeetCode , InterviewBit Solution
5 Check if a linked list is Palindrome LeetCode , InterviewBit Solution
6 Rotate a LinkedList LeetCode , InterviewBit Solution
7 Reverse linked list in a group of given size k LeetCode , InterviewBit Solution
8 Detect and Remove Loop in a linked list LeetCode , InterviewBit Solution
9 Find length of the Loop in a linked list GFG Solution
10 Segregate even and odd positioned nodes in a linked list LeetCode , GFG Solution
11 Segregate even and odd valued nodes in a linked list GFG Solution
12 Clone a linked list with next and random pointer LeetCode , GFG
13 Reorder List L1->L2->...Ln to L1->Ln->L2->Ln-1.... LeetCode , InterviewBit Solution
14 Delete N nodes after M nodes of a linked list GFG Solution
15 Merge K sorted list LeetCode , InterviewBit , GFG Solution
16 Add two numbers represented by a linked list LeetCode , InterviewBit Solution

Stack

ID PROBLEM STATEMENT PROBLEM LINK SOLUTIONS
1 Valid Parentheses LeetCode Solution
2 Length of longest valid Parentheses LeetCode Solution
3 Next Greater Element GFG , LeetCode Solution
4 Nearest Smaller Element InterviewBit Solution
5 Trapping Rain Water LeetCode , InterviewBit Solution
6 Largest Rectangle in a Histogram LeetCode , InterviewBit Solution
7 Min Stack LeetCode , InterviewBit Solution

Queue

ID PROBLEM STATEMENT PROBLEM LINK SOLUTIONS
1 Generate binary numbers from 1 to n GFG Solution
2 Minimum time required to rot all Oranges GFG , LeetCode Solution
3 First non repeating character in a stream GFG Solution
4 Circular tour GFG , LeetCode Solution
5 Sliding Window Maximum LeetCode , InterviewBit Solution

Binary Tree

ID PROBLEM STATEMENT PROBLEM LINK SOLUTIONS
1 Determine Height of a binary tree LeetCode , InterviewBit Solution
2 Inorder Traversal InterviewBit Solution
3 Preorder Traversal InterviewBit Solution
4 Postorder Traversal InterviewBit Solution
5 Level Order Traversal LeetCode Solution
6 Level Order Traversal in Spiral Form LeetCode , InterviewBit Solution
7 Left and Right View of Binary Tree LeetCode Solution
8 Diameter of a Binary tree LeetCode Solution
9 Populating Next Right Pointers in Each Node LeetCode , InterviewBit Solution
10 Check if a Binary Tree is Sum Tree GFG Solution
11 Check if a Binary Tree is Balanced LeetCode , InterviewBit Solution
12 Check if a Binary Tree is BST GFG Solution
13 Convert a given Binary Tree into its mirror Tree GFG Solution
14 Check if two Binary Tree are mirror image of each other GFG Solution
15 Check if a Binary Tree is Symmetric Binary Tree InterviewBit , LeetCode Solution
16 Invert a Binary Tree InterviewBit , LeetCode Solution
17 Vertical order Traversal InterviewBit Solution
18 Top View Of Binary Tree GFG Solution
19 Bottom View of Binary Tree GFG Solution
20 Check if Root to Leaf path sum exist InterviewBit , LeetCode Solution
21 All Root to Leaf path sum InterviewBit , LeetCode Solution
22 Maximum path sum from leaf to leaf CodingNinjas Solution
23 Maximum path sum from any node to any node LeetCode Solution
24 Least Common Ancestor LeetCode Solution
25 Find the distance between two nodes of a Binary Tree GFG Solution

Binary Search Tree

ID PROBLEM STATEMENT PROBLEM LINK SOLUTIONS
1 Insert a Node in BST LeetCode Solution
2 Delete a Node from BST LeetCode Solution
3 Lowest common ancestor in BST LeetCode Solution
4 Inorder Successor in BST LeetCode Solution
5 Kth Smallest node in BST LeetCode Solution

Heap and Priority Queue

ID PROBLEM STATEMENT PROBLEM LINK SOLUTIONS
1 Median in a stream of integers GFG Solution
2 Top K Frequent Elements in an Array LeetCode Solution
3 Kth Largest Element in a Stream LeetCode Solution
4 Sort a nearly sorted (or K sorted) array GFG Solution
5 Kth Smallest Element in a Sorted Matrix LeetCode Solution

Algorithms

Binary Search

ID PROBLEM STATEMENT PROBLEM LINK SOLUTIONS
1 Find First and Last Position of Element in Sorted Array LeetCode Solution
2 Search in Rotated Sorted Array LeetCode , InterviewBit , GFG Solution
3 Find Minimum in Rotated Sorted Array LeetCode Solution
4 Pow(x,n) LeetCode , InterviewBit Solution
5 Sqrt(n) LeetCode , InterviewBit Solution
6 Matrix Search LeetCode , InterviewBit Solution
7 Median of Two Sorted Arrays LeetCode , InterviewBit Solution

Dynamic Programming

ID PROBLEM STATEMENT PROBLEM LINK SOLUTIONS
1 Climbing Stairs LeetCode Solution
2 Coin Sum Infinite InterviewBit Solution
3 Min Cost Climbing Stairs LeetCode Solution
4 Rod Cutting Problem GFG Solution
5 Longest Common Subsequence LeetCode Solution
6 Print Longest Common Subsequence Hackerrank Solution
7 Longest Increasing Subsequence LeetCode , InterviewBit Solution
8 Edit Distance LeetCode Solution
9 Longest Common Substring LeetCode Solution
10 Maximum Sum Contiguous Subarray LeetCode Solution
11 Maximum Sum without adjacent Element(House Robber) LeetCode Solution
12 Maximum Product Subarray LeetCode Solution
13 Find minimum number of coins that make a given value LeetCode Solution
14 Min Cost Path InterviewBit Solution
15 Maximal Rectangle LeetCode , InterviewBit Solution
16 Minimum Jump to reach End LeetCode , InterviewBit Solution
17 0 - 1 Knapsack Problem GFG Solution
18 Partition Equal Subset Sum LeetCode Solution
19 Longest Palindromic Subsequence LeetCode Solution
20 Longest Bitonic Subsequence InterviewBit Solution
21 Word Break LeetCode , InterviewBit Solution
22 Interleaving String LeetCode , InterviewBit Solution
23 Matrix Chain Multiplication LeetCode Solution
24 Palindrome Partitioning LeetCode Solution

Graph

ID PROBLEM STATEMENT PROBLEM LINK SOLUTIONS
1 Region in Binary Matrix InterviewBit , GFG Solution
2 Rotting Oranges LeetCode , GFG Solution
3 Number of Islands LeetCode , GFG Solution
4 Find whether path exist InterviewBit , GFG Solution
5 Cycle in Undirected Graph InterviewBit , GFG Solution
6 Cycle in Directed Graph InterviewBit , LeetCode Solution
7 Topological Sort LeetCode Solution
8 Snakes and Ladders LeetCode , InterviewBit Solution
9 Alien Dictionary GFG Solution
10 Word Search LeetCode , InterviewBit Solution
11 Word Search 2 LeetCode , GFG Solution
12 Word Ladder InterviewBit , LeetCode Solution