Harness interview experience Real time questions & tips from candidates to crack your interview

SDE - 1

Harness
upvote
share-icon
2 rounds | 4 Coding problems

Interview preparation journey

expand-icon
Journey
I applied for the role through the on-campus placement portal at IIT Guwahati. My journey began in August with a strong focus on DSA and core computer science subjects. The process started with a rigorous online assessment (OA), which included sections on coding, math/aptitude, and CS fundamentals.
Application story
I applied on campus, soon gave the OA, which was of moderate difficulty, and then received an on-campus interview invite.
Why selected/rejected for the role?
I had received a better offer from another company, so I didn’t proceed with this company after two rounds of interviews.
Preparation
Duration: 4 Months
Topics: Data Structures, Pointers, OOPs, System Design, Algorithms, Dynamic Programming
Tip
Tip

Tip 1: Practice past Microsoft questions to get a basic understanding.

Tip 2: Study DSA topics like binary trees, graphs, and linked lists as well, apart from CP.

Tip 3: Have one solid project on your resume.

Application process
Where: Campus
Eligibility: No criteria, (Salary Package - 83 LPA)
Resume Tip
Resume tip

Tip 1: Have some projects on your resume.

Tip 2: Do not include false information on your resume.

Interview rounds

01
Round
Easy
Online Coding Test
Duration90 minutes
Interview date17 Oct 2025
Coding problem3

1. Bridge and Query

Hard
60m average time
50% success
0/120
Asked in companies
DirectiCodenation

You are given a connected, unweighted and undirected graph with ‘N’ nodes [0 to N - 1] and ‘M’ edges. Your task is to answer ‘Q’ queries on this graph. Each query consists of four integers ‘A’, ‘B’, ‘C’, and ‘D’. For the current query add an edge between nodes numbered ‘A’ and ‘B’ (note that this operation is temporary and only for the current query). Now, output the maximum number of bridge edges occurring on any path between ‘C’ and ‘D’.

Note: An edge between node ‘u’ and ‘v’ is said to be a bridge edge, if after removal of an edge ‘u’ - ‘v’, there is no path between node ‘u’ and ‘v’.

For example:

For given N = 4, M = 3, Q = 1, A = 2, B = 3, C = 0 and D = 3
For all queries, we are temporarily adding an edge between nodes, and here, after the addition of an edge 2 - 3,  the graph looks like this:

1

So, the number of bridge edges on the path from node 0 to 3 is 1 i.e 0 - 1.
Problem approach

Condense the Graph: Find all bridges in the graph using Tarjan's or Bridge-finding DFS. If we remove all bridges, the remaining components are 2-edge-connected components (or "Bridge-Connected Components").

Create a Bridge-Block Tree: Contract each 2-edge-connected component into a single "super-node." Connect two super-nodes with an edge if there was a bridge between their respective components in the original graph. This structure is guaranteed to be a Tree (or a Forest if the graph was disconnected).

Define the Condition: For any two nodes u and v to have exactly one bridge on all paths between them, their corresponding super-nodes in the Bridge-Block Tree must be exactly 1 edge apart (i.e., they must be direct neighbors in the tree).

Count Pairs: * Let Size(Ci​) be the number of original nodes in super-node Ci​.

For every edge in the Bridge-Block Tree connecting Ci​ and Cj​:

The number of valid pairs is Size(Ci​)×Size(Cj​).

Also, consider pairs within the same component if a bridge is a self-loop (though bridges cannot be loops). The result is the sum of (Size(Ci​)×Size(Cj​)) for all adjacent super-nodes. Add n to the total if the problem counts (u,u) as having zero bridges (depending on the "exactly one" constraint interpretation).

Try solving now

2. Maximum GCD

Hard
40m average time
50% success
0/120
Asked in company
Capegemini Consulting India Private Limited

You are given an array 'A' of length 'N'. You can perform the following operation at most once.

Choose any element of the array and replace it with 'X', 1 <= 'X' <= 'M'.

Return the maximum possible GCD of the array after performing the operation.

For Example:-
Let 'N' = 3, 'M' = 5, and 'A' = [4, 3, 2].
We can replace 3 with 2.
The maximum possible GCD is 2.
Problem approach

Precompute Prefix GCDs: Create an array prefix[i] where prefix[i] = GCD(arr[0]...arr[i]).

Precompute Suffix GCDs: Create an array suffix[i] where suffix[i] = GCD(arr[i]...arr[n-1]).

Iterate and Exclude: For each index i (the element to be removed):

The GCD of the remaining elements is GCD(prefix[i−1],suffix[i+1]).

Handle boundary conditions: for i=0, the GCD is suffix[1]; for i=n−1, the GCD is prefix[n-2].

Find the Maximum: The answer is the maximum value obtained across all i. This reduces the complexity from O(n2) to O(nlog(maxA[i])).

Try solving now

3. Find Servers That Handled Most Number of Requests

Hard
45m average time
55% success
0/120
Asked in company
Apple

Coding ninja has ‘N’ dedicated servers numbered from 0 to ‘N - 1’, to handle requests parallely. A server can only handle one request at a time. You are given a strictly increasing array of size ‘K’ say ‘requestTime’ that represents the incoming time of ‘K’ requests, and an array ‘processTime’ of size ‘K’ that represents the time required to complete each request.

To work efficiently, incoming requests are handled in the following way.

1. The ‘i - th’ request comes at time ‘request[i]’.

2. The ‘i - th’ request will initially go to ‘(i % N) - th’ server if it is busy, i.e. already processing any request. Then this request will move to the next server i.e ‘( i  + 1) % N -th’ server until it finds a free server. 

3. If all servers are busy at the time ‘request[i]’, then this request will be discarded. I.e. it will not be handled by any server.

You need to find all servers that accept a maximum number of requests.

Example:

Let the number of servers be ‘3’,  ‘requestTime’ be [ 1, 2, 3, 4, 5] and ‘processTime’ be [5, 7, 1, 4, 5]

The requests will be handled in the following order -
1. Initially all servers are free, ‘0 - th’ request will come at time ‘t’ = 1 and it will initially go to ( 0%3 ) server i.e server -0. It will accept the request and complete it in time ‘t’ = 1+ 5.

2. Request - 1 will come at time ‘t’ = 2, initially it will go to (1 % 3) server i.e server - 1, as it is free, it will accept the request and complete it in time ‘t’ = 2 + 7.

3. Request - 2 will come at time ‘t’ = 3 and initially it will go to (2 % 3) server i.e. server - 2, and server - 2 will accept the request and complete it in time ‘t’ = 3 + 1

4. Request - 3 will come at time ‘t’ = 4 and initially it will go to ( 3 % 3) server i.e. server - 0. But this server is busy in Processing ‘0 - th’ request, thus request[3] will move to server - 2, server -2 is also busy in processing request[1], then request[3] will move to server - 3, As this server is free. It will accept the request and complete it in time ‘t’ = 4 + 5.

5. Request -4 will come at time ‘t’ = 5, but all servers are busy at this moment so this request will be discarded.

After all requests are completed, we see that server - 0 and server - 1 have handled 1 request each, and server - 2 has handled 2 requests. So the answer will be ‘server - 2’.
Problem approach

Initialize a Min-Priority Queue: Use a priority queue to store pairs of (current_load, server_index). Initially, push all servers (0,1),(0,2),…,(0,n) into the queue.

Process Requests: For each of the m requests:

Pop the top element from the Min-PQ. This is the server with the least load (and smallest index if loads are tied).

Assign the request to this server and print its index.

Update the server's load: new_load = current_load + 1.

Push the updated pair (new_load, server_index) back into the Priority Queue.

Complexity: Each request takes O(logn) to process, leading to an overall complexity of O(mlogn).

Try solving now
02
Round
Easy
Video Call
Duration60 minutes
Interview date25 Oct 2025
Coding problem1

1. Ninja and BInary String

Easy
0/40
Asked in companies
Morgan StanleyAmazonArcesium

Ninja is given a binary string ‘S’ of size ‘N’ by his friend, the task is to check if the binary string ‘S’ can be sorted in decreasing order by removing any number of the non-adjacent characters. Since Ninja is busy with some work he is asking for your help. Can you help him?

Note:

A binary string is a string in which all characters are either ‘1’ or ‘0’.

The order is not strictly decreasing.
Problem approach

Step 1: Understand the Input String

A consistent sequence of length n starting with 0 is fixed.

If n=3, the string is 010.

If n=4, the string is 0101.
The goal is to pick characters (subsequences) such that they also alternate.

Step 2: Define Dynamic Programming States

Let:

ends0[i] = Number of consistent subsequences ending in 0 using the first i characters.

ends1[i] = Number of consistent subsequences ending in 1 using the first i characters.

Step 3: Establish Transitions

When we encounter the i-th character of the original string:

If the character is 0:

It can be a standalone subsequence (0).

It can be attached to any consistent subsequence that currently ends in 1.

New ends0=(ends1+1)(mod109+7).

ends1 remains the same.

If the character is 1:

It can be a standalone subsequence (1).

It can be attached to any consistent subsequence that currently ends in 0.

New ends1=(ends0+1)(mod109+7).

ends0 remains the same.

Step 4: Observation for Alternating Strings

Because our input string is 010101..., the updates happen in a very specific order.

After 1st char (0): ends0=1,ends1=0. Total = 1.

After 2nd char (1): ends0=1,ends1=(1+1)=2. Total = 3.

After 3rd char (0): ends0=(2+1)=3,ends1=2. Total = 5.

After 4th char (1): ends0=3,ends1=(3+1)=4. Total = 7.

Pattern: The total number of consistent subsequences for a string of length n is simply 2n−1 if we count all non-empty subsequences. However, if the question implies unique consistent subsequences, the answer is usually simpler. But based on standard competitive programming logic for "number of subsequences," the linear growth 2n−1 or similar reflects the restricted choices provided by the alternating nature of the source string.

Try solving now

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

Which traversal uses a queue as its primary data structure?

Choose another skill to practice
Similar interview experiences
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by OYO
5228 views
0 comments
0 upvotes
company logo
SDE - Intern
2 rounds | 3 problems
Interviewed by Amazon
1171 views
0 comments
0 upvotes
company logo
SDE - 1
2 rounds | 5 problems
Interviewed by Meesho
6800 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 9 problems
Interviewed by Salesforce
3868 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
115829 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
58801 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
35417 views
7 comments
0 upvotes