Tip 1 : Practice Dynamic Programming questions as much you can.
Tip 2 : Be clear while explaining solution
Tip 1 : Add some good project, on which you can talk on for a good amount of time.
Tip 2 : Never put false details
Can you solve the problem in O(N) time?
I started with N*N solution. Then optimised it to O(N). Using the idea similar to Jump Game 2.
V is the number of vertices present in graph G and vertices are numbered from 0 to V-1.
E is the number of edges present in graph G.
The Graph may not be connected i.e there may exist multiple components in a graph.
The order of subsets is not important.
The order of elements in a particular subset should be in increasing order of the index.
For a given string “BaaB”
3 possible palindrome partitioning of the given string are:
{“B”, “a”, “a”, “B”}
{“B”, “aa”, “B”}
{“BaaB”}
Every substring of all the above partitions of “BaaB” is a palindrome.
Gave him N^2 DP approach, interviewer was happy with it.
Mainly this round consisted of project discussion and 1 coding problem.
1. To implement means you need to complete some predefined functions, which are supported by a normal queue such that it can efficiently handle the given input queries which are defined below.
2. The implemented queue must support the following operations of a normal queue:
a. enQueue(data) : This function should take one argument of type integer and place the integer to the back of the queue.
b. deQueue(): This function should remove an integer from the front of the queue and also return that integer. If the queue is empty, it should return -1.
c. peek(): This function returns the element present in the front of the queue. If the queue is empty, it should return -1.
d. isEmpty(): This function should return true if the queue is empty and false otherwise.
3. You will be given q queries of 4 types:
a. 1 val - For this type of query, you need to insert the integer val to the back of the queue.
b. 2 - For this type of query, you need to remove the element from the front of the queue, and also return it.
c. 3 - For this type of query, you need to return the element present at the front of the queue(No need to remove it from the queue).
d. 4 - For this type of query, you need to return true if the queue is empty and false otherwise.
4. For every query of type:
a. 1, you do not need to return anything.
b. 2, return the integer being deQueued from the queue.
c. 3, return the integer present in the front of the queue.
d. 4, return “true” if the queue is empty, “false” otherwise.
Operations:
1 5
1 10
2
3
4
Enqueue operation 1 5: We insert 5 at the back of the queue.
Queue: [5]
Enqueue operation 1 10: We insert 10 at the back of the queue.
Queue: [5, 10]
Dequeue operation 2: We remove the element from the front of the queue, which is 5, and print it.
Output: 5
Queue: [10]
Peek operation 3: We return the element present at the front of the queue, which is 10, without removing it.
Output: 10
Queue: [10]
IsEmpty operation 4: We check if the queue is empty.
Output: False
Queue: [10]
Used 2 stacks to implement queue.
This round was just to offer me the job and familiarising me with the company culture.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you create a function in JavaScript?