Tip 1: Practice DSA problems consistently and focus on understanding the logic behind each solution rather than memorizing patterns.
Tip 2: Strengthen core subjects like Computer Networks, Operating Systems, and DBMS, as many interviews focus on fundamentals.
Tip 3: Work on a few strong projects and be prepared to explain the design, technologies used, and challenges faced.
Tip 1: Highlight strong projects and internships that clearly demonstrate your technical skills and problem-solving ability.
Tip 2: Keep the resume concise and only include technologies or concepts that you can confidently explain during the interview.



In the following directed graph has a cycle i.e. B->C->E->D->B.

1. The cycle must contain at least two nodes.
2. It is guaranteed that the given graph has no self-loops in the graph.
3. The graph may or may not be connected.
4. Nodes are numbered from 1 to N.
5. Your solution will run on multiple test cases. If you are using global variables make sure to clear them.
Step 1: I first clarified the problem and understood that detecting cycles in a directed graph requires tracking the traversal path.
Step 2: Initially, I considered using a simple DFS traversal to visit all nodes in the graph.
Step 3: I maintained two arrays: one visited array to track visited nodes and another recursion stack array to track nodes currently in the DFS path.
Step 4: During the DFS traversal, if I encountered a node that was already present in the recursion stack, it indicated the presence of a cycle in the graph.
Step 5: If a neighboring node was not visited, I recursively performed DFS on that node.
Step 6: After exploring all neighbors of a node, I removed it from the recursion stack before returning.
Step 7: If any DFS call detected a cycle, I returned true; otherwise, after checking all nodes, the graph was considered acyclic.



Input:
4 5
0 1 5
0 2 8
1 2 9
1 3 2
2 3 6

In the given input, the number of vertices is 4, and the number of edges is 5.
In the input, following the number of vertices and edges, three numbers are given. The first number denotes node ‘X’, the second number denotes node ‘Y’ and the third number denotes the distance between node ‘X’ and ‘Y’.
As per the input, there is an edge between node 0 and node 1 and the distance between them is 5.
The vertices 0 and 2 have an edge between them and the distance between them is 8.
The vertices 1 and 2 have an edge between them and the distance between them is 9.
The vertices 1 and 3 have an edge between them and the distance between them is 2.
The vertices 2 and 3 have an edge between them and the distance between them is 6.
1. There are no self-loops(an edge connecting the vertex to itself) in the given graph.
2. There can be parallel edges i.e. two vertices can be directly connected by more than 1 edge.
Step 1: I first clarified the requirements and understood that we need to find not just the shortest path but the K shortest distinct paths, which cannot be solved using a simple shortest path algorithm alone.
Step 2: Initially, I considered using Dijkstra’s algorithm to find the shortest path from the source to the destination.
Step 3: After finding the first shortest path, I used the idea of modifying the path by deviating at different nodes to generate alternative candidate paths.
Step 4: I maintained a priority queue (min-heap) to store candidate paths based on their total cost.
Step 5: Each time the minimum-cost path was extracted from the heap, it was added to the final answer list.
Step 6: From that path, I generated new candidate paths by changing segments of the route and pushed them back into the priority queue.
Step 7: I repeated the process until K paths were found or no more candidate paths were available.
Step 8: Finally, the algorithm returned the K shortest paths in increasing order of cost.



An island is a 4-directionally (North, South, East, West) connected group of 1s.
Input: 'grid' = [[1,0],
[0,1]]
Output: 3
Explanation:
We can change the 0 at (0,1) to 1 and get an island of size 3.
Step 1: I first clarified the problem and understood that islands are groups of connected 1s, and we are allowed to convert one 0 to 1 to maximize the island size.
Step 2: I started by traversing the grid and labeling each existing island using DFS while calculating its size.
Step 3: I stored the size of each island with a unique island ID in a hash map.
Step 4: After identifying all islands, I iterated over every cell containing 0 to check the potential island size if that cell was converted to 1.
Step 5: For each 0 cell, I looked at its four neighboring cells and collected the unique island IDs connected to it.
Step 6: I summed the sizes of those unique islands and added 1 for the flipped cell to calculate the new island size.
Step 7: I kept track of the maximum possible island size obtained from all such conversions.
Step 8: Finally, I returned the maximum island size after considering all possible flips.



You can only move down or right at any point in time.
Step 1: I first clarified the problem constraints and realized that we need to find the shortest path in a grid while also keeping track of the number of obstacles we can eliminate.
Step 2: Since we need the shortest path, I decided to use Breadth-First Search (BFS) because it guarantees the shortest path in an unweighted grid.
Step 3: I created a queue to store the current position along with the number of obstacles eliminated so far.
Step 4: I maintained a visited structure that tracked cells along with the remaining number of obstacle eliminations to avoid revisiting inefficient states.
Step 5: During traversal, for each cell, I explored its four neighboring cells and checked whether they were inside the grid.
Step 6: If the next cell contained an obstacle, I checked whether I still had remaining eliminations available before moving into that cell.
Step 7: I pushed valid states into the queue and continued the BFS traversal level by level.
Tip 1 : Focus on understanding process synchronization, deadlocks, and memory management concepts thoroughly.
Tip 2 : Practice explaining concepts with diagrams and real-life examples for better clarity in interviews.
Tip 3 : Revise important topics like paging, segmentation, scheduling algorithms, and concurrency problems regularly.
Design a distributed system that can monitor thousands of network devices such as routers, switches, and servers in real time. The system should collect metrics like CPU usage, packet loss, latency, bandwidth utilization, and device status, and generate alerts when abnormal behavior is detected.
Tip 1: Start by defining functional and non-functional requirements like scalability, latency, and reliability.
Tip 2: Design a high-level architecture including collectors, load balancers, message queues (like Kafka), processing services, and time-series databases.
Tip 3: Discuss optimizations such as data aggregation, caching, distributed storage, and fault-tolerant services to handle large-scale network monitoring.

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?