Tip 1: Practice at least 250–300 DSA questions to build confidence across common patterns.
Tip 2: Revise core subjects like OOPS, DBMS, and OS thoroughly, as these are frequently asked.
Tip 3: Work on at least one good project and understand every detail of its implementation.
Tip 1: Add at least two well-explained projects and be ready to discuss their implementation in detail.
Tip 2: Keep the resume clean, honest, and skill-focused; avoid adding anything you can’t justify during the interview.
The test was scheduled in the morning and had to be taken within a fixed login window. It was a web-proctored assessment with webcam monitoring, so the environment needed to be quiet and distraction-free. The interface was stable, and all instructions were clearly mentioned in the email. Since it was an online coding test, there was no interviewer present — only automated proctoring.
Step 1: I first performed a DFS traversal to record the subtree range of every node using in-time and out-time in an Euler Tour array. This helped convert each subtree into a continuous segment.
Step 2: After flattening the tree, each subtree query became:
“Count distinct values in the array segment [in[u], out[u]].”
Step 3: To process distinct queries efficiently, I used a technique like Mo’s Algorithm on Trees or DSU on Tree (small-to-large merging).
I chose the DSU-on-Tree approach:
Step 4: For each query node uuu, once its subtree data structure was ready, I returned the count of distinct values.
Step 5: I optimized the solution to run in approximately O(N log N) or O(N sqrt{N}), depending on the method used, which is suitable for large constraints.
Step 1: I analyzed that each box must contain a continuous subarray, so the problem becomes splitting the array into K segments.
Step 2: I used dynamic programming, where dp[k][i] represents the maximum total distinct count when dividing first i elements into k boxes.
Step 3: To speed up transitions, I maintained frequency of elements using a sliding window while trying all valid segment breaks.
Step 4: For each possible segment end, I computed the distinct count on the fly and updated the DP table.
Step 5: Optimized it using prefix techniques to avoid recomputation and ensure it fits within constraints
Step 1: Observed that each segment must be a continuous subarray, so dynamic programming is suitable. Let dp[k][i] store the minimum cost for dividing the first i elements into k segments.
Step 2: Calculated segment costs using two pointers and frequency maps to track first/last occurrences and compute the cost of the current segment efficiently.
Step 3: Iterated possible split points for each segment and updated dp values:
dp[k][i] = min(dp[k][i], dp[k-1][j] + cost(j+1, i)).
Step 4: Used an optimized technique (like maintaining frequency arrays and incremental updates) to compute the cost of sliding windows without recomputing from scratch.
Step 5: Filled the DP table for all K segments and returned dp[K][N] as the minimum possible cost.
The interview was scheduled around noon, and the environment at the Infosys campus was calm and professional. All shortlisted candidates were asked to wait in the lobby until their turn. The interviewer was polite and focused mainly on my problem-solving approach, core subjects, and project understanding. The discussion was detailed yet comfortable, and the interviewer provided guidance whenever needed without adding pressure. Overall, the experience was structured, smooth, and well-organized.
Step 1: First, I tried the direct brute-force solution: iterating from 1 to N, converting each number to a string, and counting the digit ‘0’. I explained this clearly to the interviewer.
Step 2: The interviewer asked whether this approach would work for large values of N. I explained the time complexity and why it becomes slow.
Step 3: Then, I discussed the optimized mathematical approach that counts zeros digit by digit using positional analysis (units, tens, hundreds).
This method uses the idea of breaking N into left, current, and right parts to compute how many zeros appear at each position.
Step 4: I explained the logic with an example and showed how the optimized solution works in O(log N) time.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
To make an AI less repetitive in a long paragraph, you should increase: