Tip 1: Practice DSA problems regularly and focus on strengthening core concepts like arrays, strings, trees, and dynamic programming.
Tip 2: Revise core subjects such as DBMS, Operating Systems, and Computer Networks thoroughly for technical interviews.
Tip 3: Prepare basic system design concepts and practice explaining solutions in a structured way during interviews.
Tip 1: Keep your resume concise and clearly highlight relevant projects, internships, and technical skills.
Tip 2: Only mention the technologies and concepts that you are confident about explaining in an interview.



If there is no path between 'src' and 'ith' vertex, the value at 'ith' index in the answer array will be 10^8.

3 3 1
1 2 2
1 3 2
2 3 -1
In the above graph:
The length of the shortest path between vertex 1 and vertex 1 is 1->1 and the cost is 0.
The length of the shortest path between vertex 1 and vertex 2 is 1->2 and the cost is 2.
The length of the shortest path between vertex 1 and vertex 3 is 1->2->3 and the cost is 1.
Hence we return [0, 2, 1].
It's guaranteed that the graph doesn't contain self-loops and multiple edges. Also, the graph does not contain negative weight cycles.
Step 1: I first discussed the problem with the interviewer and clarified that the graph could contain negative edge weights, so algorithms like Dijkstra’s would not work correctly.
Step 2: I decided to use the Bellman-Ford algorithm, which works for graphs with negative edge weights and can also detect negative cycles.
Step 3: I initialized the distance of all nodes to infinity and set the distance of the source node to 0.
Step 4: I relaxed all edges V−1 times (where V is the number of vertices). For every edge (u, v), if dist[u] + weight < dist[v], I updated dist[v].
Step 5: After performing V−1 relaxations, I ran one more iteration over all edges to check whether any distance could still be reduced.
Step 6: If any distance was updated in this extra iteration, it meant that a negative-weight cycle existed in the graph.
Step 7: Finally, I returned the shortest distances from the source node to all other nodes or reported the presence of a negative cycle.



Down: (row+1,col)
Right: (row, col+1)
Down right diagonal: (row+1, col+1)
Step 1: I first considered solving the problem using recursion by exploring all possible paths from the starting cell.
Step 2: I realized that many subproblems were repeating, which would make the recursive solution inefficient.
Step 3: I then applied Dynamic Programming using a DP table, where dp[i][j] represents the minimum cost to reach cell (i, j).
Step 4: I initialized the first row and first column based on cumulative costs.
Step 5: For each cell, I calculated the minimum cost using:
dp[i][j] = cost[i][j] + min(dp[i-1][j], dp[i][j-1], dp[i-1][j-1]).
Step 6: The value at dp[m-1][n-1] gives the final minimum path cost.



Print -1 if a node is not reachable from the given source node.
Consider the following DAG consists of 5 nodes and 7 edges, Let the source node ‘Src’ be 0.

Then the maximum distance of node 0 from the source node 0 is 0. (the distance of a node from itself is always 0).
The maximum distance of node 1 from the source node 0 is 3. The path that gives this maximum distance is 0 -> 1.
The maximum distance of node 2 from the source node 0 is 10. The path that gives this maximum distance is 0 -> 2.
The maximum distance of node 3 from the source node 0 is 15. The path that gives this maximum distance is 0 -> 2 -> 3.
The maximum distance of node 4 from the source node 0 is 54. The path that gives this maximum distance is 0 -> 1 -> 4.
Thus we should print 0 3 10 15 54
Step 1: I first clarified that the graph is a DAG, which allows the use of topological ordering.
Step 2: I performed topological sorting of the graph using DFS or Kahn’s algorithm.
Step 3: I initialized all distances to negative infinity and set the source distance to 0.
Step 4: I processed the nodes in topological order and relaxed all outgoing edges.
Step 5: For each edge (u, v) with weight w, I updated:
dist[v] = max(dist[v], dist[u] + w).
Step 6: After processing all nodes, the distance array contained the longest path from the source to all other nodes.
The round was conducted during the daytime in an online mode. The overall environment was professional and comfortable. The interviewer was friendly and gave me time to think through the problems. The discussion was interactive, and the interviewer encouraged me to explain my approach step by step. The focus was mainly on problem-solving and understanding my thought process while designing the solution.



1. If there is no possible path to change BEGIN to END then just return -1.
2. All the words have the same length and contain only lowercase english alphabets.
3. The beginning word i.e. BEGIN will always be different from the end word i.e. END (BEGIN != END).
Step 1: I first clarified that the task is to find all the shortest transformation sequences between the begin word and the end word.
Step 2: I converted the word list into a hash set so that lookups could be done in constant time.
Step 3: I used Breadth-First Search (BFS) starting from the begin word because BFS guarantees the shortest path in an unweighted graph.
Step 4: For each word, I generated all possible words by changing one character at a time and checked whether the new word existed in the dictionary.
Step 5: I maintained a mapping of each word to its previous words to reconstruct the shortest paths later.
Step 6: Once the end word was reached in BFS, I stopped expanding further levels and started reconstructing all paths using backtracking.
Step 7: Finally, I returned all the shortest transformation sequences obtained from the backtracking process.



Step 1: I first understood that land is added dynamically, and after each addition, we must calculate the number of islands.
Step 2: I used the Union-Find (Disjoint Set) data structure to efficiently manage connected components.
Step 3: Initially, the grid contained only water, and the island count was zero.
Step 4: Whenever a new land position was added, I treated it as a new island and increased the island count.
Step 5: I checked its four neighboring cells (up, down, left, right).
Step 6: If any neighbor was already land, I performed a union operation to merge the islands and reduced the island count.
Step 7: After processing the neighbors, I recorded the current island count.
Step 8: Finally, I returned the list containing the island count after each land addition.
Design a social media feed system (like Twitter).
Design a scalable system where users can post tweets, follow other users, and view a personalized news feed containing tweets from people they follow. The system should support millions of active users, handle high read/write traffic, and provide fast feed updates.
Key Requirements:
Tip 1: Start by identifying functional and non-functional requirements such as scalability, latency, and availability.
Tip 2: Design a high-level architecture including components like load balancers, API servers, databases, caching systems, and message queues.
Tip 3: Discuss optimizations like feed generation strategies (fan-out on write vs. fan-out on read), caching, database sharding, and CDN usage to handle large-scale traffic.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which traversal uses a queue as its primary data structure?