Housing.com interview experience Real time questions & tips from candidates to crack your interview

Software Engineer

Housing.com
upvote
share-icon
4 rounds | 12 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 6 months
Topics: Data Structures, Algorithms, System Design, Aptitude, OOPS
Tip
Tip

Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.

Application process
Where: Campus
Eligibility: Above 7 CGPA
Resume Tip
Resume tip

Tip 1 : Make a cv which is appealing, and highlight some key things regarding web development or algorithms or system development
Tip 2 : Have at-least 2 good projects explained in short with all important points covered.

Interview rounds

01
Round
Easy
Face to Face
Duration60 minutes
Interview date26 Jan 2015
Coding problem3

Technical round with questions based on data structures and algorithms.

1. Count Inversions

Moderate
40m average time
55% success
0/80
Asked in companies
Hewlett Packard EnterpriseBNY MellonGrab

For a given integer array/list 'ARR' of size 'N' containing all distinct values, find the total number of 'Inversions' that may exist.

An inversion is defined for a pair of integers in the array/list when the following two conditions are met.

A pair ('ARR[i]', 'ARR[j]') is said to be an inversion when:

1. 'ARR[i] > 'ARR[j]' 
2. 'i' < 'j'

Where 'i' and 'j' denote the indices ranging from [0, 'N').
Problem approach

The idea is to use a method similar to the merge sort algorithm. Like merge sort, divide the given array into two parts. For each left and right half, count the inversions, and at the end, sum up the inversions from both halves to get the resultant inversions.
Algorithm: 
1. Divide the array into two equal or almost equal halves in each step until the base case is reached.
2. Create a function merge that counts the number of inversions when two halves of the array are merged, create two indices i and j, i is the index for the first half, and j is an index of the second half. if a[i] > a[j], then there are (mid – i) inversions. because left and right subarrays are sorted, so all the remaining elements in left-subarray (a[i+1], a[i+2] … a[mid]) will be greater than a[j].
3. Create a recursive function to divide the array into halves and find the answer by summing the number of inversions is the first half, the number of inversions in the second half and the number of inversions by merging the two.
4. The base case of recursion will be when there is only one element in the given half.
5. Print the number of total inversions.

Time Complexity: O(NlogN), where N is the total size of the array
Space Complexity: O(N), where N is the total size of the array

Try solving now

2. Add Two Numbers As Linked Lists

Moderate
20m average time
80% success
0/80
Asked in companies
SprinklrIBMDeutsche Bank

You are given two non-negative numbers 'num1' and 'num2' represented in the form of linked lists.


The digits in the linked lists are stored in reverse order, i.e. starting from least significant digit (LSD) to the most significant digit (MSD), and each of their nodes contains a single digit.


Calculate the sum of the two numbers and return the head of the sum list.


Example :
Input:
'num1' : 1 -> 2 -> 3 -> NULL
'num2' : 4 -> 5 -> 6 -> NULL

Output: 5 -> 7 -> 9 -> NULL

Explanation: 'num1' represents the number 321 and 'num2' represents 654. Their sum is 975.


Problem approach

For every digit in the number, make a new node and attach it to the previous node in the list. 
Steps:
1. Run a while loop while the number > 0. 
2. Extract digit from the number by num%10 and update number to num%10. 
3. Make a new node with its value as the digit and attach it at the end of the list created. 
4. Return the head of the list created.

Try solving now

3. Connect Nodes at Same Level

Moderate
30m average time
70% success
0/80
Asked in companies
Expedia GroupMicrosoftOla

A binary tree is a tree where each node has at most two children i.e left child and right child.

You are given a binary tree, where the structure of the node is as follow -:

class BinaryTreeNode {
 int data;      // Value of the node.
 BinaryTreeNode *left;  // Pointer to left child node.
 BinaryTreeNode *right; // Pointer to right child node.
 BinaryTreeNode *next;  // Pointer to next right node at same level. 
}

Your task is to connect all the adjacent nodes at the same level in the given binary tree. You can do this by populating each 'next' pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL. Initially, all the next pointers are set to NULL.

For Example:

Consider the figure shown below. The left part represents the initial binary tree and right part represents the binary tree after connecting adjacent nodes at the same level.

alt text

In the tree shown in the picture above -:
The ‘next’ pointer of the node having value 2 is connected to the node having value 3.
The ‘next’ pointer of the node having value 4 is connected to the node having value 5.
The ‘next’ pointer of the node having value 5 is connected to the node having value 6.
The ‘next’ pointer of nodes having value 1, 3, 6 will have a value NULL as there are no next right nodes in their cases.

Note:

1. The structure of the ‘Node’ of a binary tree is already defined. You should not change it.   
2. The root of the binary tree is known to you.  
3. There is at least one node in the given binary tree.
4. You may only use constant extra space.
Problem approach

Level order traversal can be used to solve this problem. Modify queue entries to store the node and the level of nodes. So, the queue node will contain a pointer to a tree node and an integer level. When we deque a node we can check the level of dequeued node. If it is same, set the right pointer of the node to the front node of the queue. 
Time Complexity : O(N) 
Space Complexity :O(N)

Try solving now
02
Round
Easy
Face to Face
Duration60 minutes
Interview date26 Jan 2015
Coding problem3

Technical round with questions based on data structures and algorithms.

1. Word Ladder

Hard
10m average time
90% success
0/120
Asked in companies
OlaSalesforceDisney + Hotstar

You are given two strings BEGIN and END and an array of strings DICT. Your task is to find the length of the shortest transformation sequence from BEGIN to END such that in every transformation you can change exactly one alphabet and the word formed after each transformation must exist in DICT.

Note:

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).
Problem approach

BFS can be used to solve this question. 
1. Start from the given start word and push it in queue. 
2. Maintain a variable to store the steps needed. 
3. Run a loop until the queue is empty : 
2.1 Traverse all words that are adjacent (differ by one character) to it and push the word in the queue. 
4. Keep doing so until we find the target word or we have traversed all words. Keep Incrementing the steps too. 
At last, if the target word is found return the number of steps or return 0 otherwise.

Try solving now

2. Ninja and Two Sorted Arrays

Moderate
15m average time
85% success
0/80
Asked in companies
HSBCHikeAmazon

Ninja has been given two sorted integer arrays/lists ‘ARR1’ and ‘ARR2’ of size ‘M’ and ‘N’. Ninja has to merge these sorted arrays/lists into ‘ARR1’ as one sorted array. You may have to assume that ‘ARR1’ has a size equal to ‘M’ + ‘N’ such that ‘ARR1’ has enough space to add all the elements of ‘ARR2’ in ‘ARR1’.

For example:

‘ARR1’ = [3 6 9 0 0]
‘ARR2’ = [4 10]
After merging the ‘ARR1’ and ‘ARR2’ in ‘ARR1’. 
‘ARR1’ = [3 4 6 9 10]
Problem approach

A simple approach would be to create a new arrays with size as sum of the sizes of both the arrays. Copy the elements of both the arrays in the new array and sort the array. 

A space optimized approach also exists. While traversing the two sorted arrays parallelly, if we encounter the jth second array element is smaller than ith first array element, then jth element is to be included and replace some kth element in the first array. 

Algorithm
1) Initialize i,j,k as 0,0,n-1 where n is size of arr1 
2) Iterate through every element of arr1 and arr2 using two pointers i and j respectively
if arr1[i] is less than arr2[j]
increment i
else
swap the arr2[j] and arr1[k]
increment j and decrement k

3) Sort both arr1 and arr2

Try solving now

3. Count Ways To Reach The N-th Stairs

Moderate
30m average time
80% success
0/80
Asked in companies
OYOLinkedInGrab

You have been given a number of stairs. Initially, you are at the 0th stair, and you need to reach the Nth stair.


Each time, you can climb either one step or two steps.


You are supposed to return the number of distinct ways you can climb from the 0th step to the Nth step.

Note:

Note: Since the number of ways can be very large, return the answer modulo 1000000007.
Example :
N=3

Example

We can climb one step at a time i.e. {(0, 1) ,(1, 2),(2,3)} or we can climb the first two-step and then one step i.e. {(0,2),(1, 3)} or we can climb first one step and then two step i.e. {(0,1), (1,3)}.
Problem approach

The question can be approached using recursion. The person can reach nth stair from either (n-1)th stair or from (n-2)th stair. Hence, for each stair n, find out the number of ways to reach n-1th stair and n-2th stair and add them to give the answer for the nth stair. Therefore the expression for such an approach comes out to be : ways(n) = ways(n-1) + ways(n-2)

This is an expression for Fibonacci numbers only, where ways(n) is equal to Fibonacci(n+1). 
Time Complexity: O(2^n) 
The above solution can be optimised using dynamic programming. Maintain an array dp[] and fill it in bottom up manner using the relation :
Dp[i] = dp[i-1] + dp[i-2] for i>=2 
Time complexity: O(N)
Auxiliary Space: O(N)

Try solving now
03
Round
Medium
Face to Face
Duration60 minutes
Interview date26 Jan 2015
Coding problem3

Technical round with questions based on data structures and algorithms.

1. Shortest Bridge

Moderate
35m average time
65% success
0/80
Asked in companies
UberWalmartFacebook

Every story has an Endgame. This is another such story.

Tony Stark and Thanos live in two different islands. Tony wants to reach Thanos's island in minimum time to save the world.

You are given a 2-D binary array of 'N' rows and 'M' columns. If the element of the array is 1 it means it has land in there else if the element is 0 means it has water in there. There are exactly two islands in this array. In one island Tony lives and in another island, Thanos lives. An island is a 4 – directionally connected component of 1’s.

For example

In the above figure, there are two islands coloured in brown and orange respectively.

Tony wants to build a bridge between these two islands. With the help of Friday Tony can build the bridge by changing 1 or more 0’s to 1’s. Size of the bridge is the number of 0’s changed to 1’s. Tony wants to minimize the size of the bridge as it minimizes time to reach Thanos.

For example

Here Bridge is marked in red colour and 1 is the minimum size of bridge possible.

Tony is busy assembling all the avengers, so he called you to solve this problem.

Problem approach

Concept of Longest Increasing Subsequence can be used in this problem.
Steps: 
1. Sort the north-south pairs on the basis of increasing order of south x-coordinates. If two south x-coordinates are same, then sort on the basis of increasing order of north x-coordinates.
2. Now , use LIS to find the Longest Increasing Subsequence of the north x-coordinates. Here, in the increasing subsequence , a value can be greater as well as equal to its previous value.

Try solving now

2. Overlapping Intervals

Easy
24m average time
0/40
Asked in companies
SprinklrAdobeAmazon

You have been given the start and end times of 'N' intervals. Write a function to check if any two intervals overlap with each other.

Note :
If an interval ends at time T and another interval starts at the same time, they are not considered overlapping intervals.
Problem approach

The brute force approach would be to traverse the array and run a nested loop. For each interval, count the number of intervals it intersects and at last, print the maximum number of intervals that an interval can intersect.
The above approach can be optimized counting the number of intervals that do not intersect. The intervals that do not intersect with a particular interval can be divided into two disjoint categories: intervals that fall completely to the left or completely to the right. 
Steps:
1. Create a hashmap, say M, to map the number of intervals that do not intersect with each interval.
2. Sort the intervals on the basis of their starting point.
3. Traverse the intervals using the variable i
a. Initialize ans as -1 to store the index of the first interval lying completely to the right of ith interval.
b. Initialize low and high as (i + 1) and (N – 1) and perform a binary search as below:
i. Find the value of mid as (low + high)/2.
ii. If the starting position of interval[mid] > than the ending position of interval[i], store the current index mid in ans and then check in the left half by updating high to (mid – 1).
iii. Else check in the right half by updating low to (mid + 1).
c. If the value of ans is not -1, add (N – ans) to M[interval[i]].
4. Now, sort the intervals on the basis of their ending point.
5. Again, traverse the intervals using the variable i and apply a similar approach as above to find the intervals lying completely to the left of the ith interval.
6. After the loop, traverse the map M and store the minimum value in min.
7. Print the value of (N – min) as the result.

Try solving now

3. Fix BST

Hard
45m average time
40% success
0/120
Asked in companies
OYOMicrosoftSquadstack

You have been given a Binary Search Tree of 'N' nodes, where exactly two nodes of the same tree were swapped by mistake.


Your task is to restore or fix the BST, without changing its structure and return the root of the corrected BST.


Note:

Given BST will not contain duplicates.


Example
A Binary Search Tree (BST) whose 2 nodes have been swapped is shown below.  

example

After swapping the incorrect nodes: 

example

Follow Up
Can you do this without using any extra space? 
Problem approach

Recursion can be used here. Maintain two pointers, first and second to find the 2 nodes that violate the order. At last, change the values of the two nodes by their value. 

PseudoCode : 

correctBST(Node root) {
help(root);
swap(first->val, second->val);
}

help(Node root){
if(root is NULL) return;
help(root->left);
if(first is NULL and prev->val >= root->val) first=prev;
if(first is not NULL and prev->val >= root->val) second=root;
prev=root;
help(root->right);
}

Try solving now
04
Round
Medium
Face to Face
Duration60 minutes
Interview date26 Jan 2015
Coding problem3

Technical round with questions based on System design and data structures and algorithms.

1. System Design Question

Design a system for Bookmyshow.com. When we book seats we the seats must be locked till the time payment gateway is reached. Also consider no payment done and payment failures.

Problem approach

Tip 1: Firstly, remember that the system design round is extremely open-ended and there’s no such thing as a standard answer. Even for the same question, you’ll have a totally different discussion with different interviewers.
Tip 2:Before you jump into the solution always clarify all the assumptions you’re making at the beginning of the interview. Ask questions to identify the scope of the system. This will clear the initial doubt, and you will get to know what are the specific detail interviewer wants to consider in this service.
Tip 3 : Design your structure and functions according to the requirements and try to convey your thoughts properly to the interviewer so that you do not mess up while implementing the idea .

2. System Design Question

Implement an auto suggest in search engine. Like for google when u type max say maximum must be suggested in drop down.

Problem approach

Tip 1:Before you jump into the solution always clarify all the assumptions you’re making at the beginning of the interview. Ask questions to identify the scope of the system. This will clear the initial doubt, and you will get to know what are the specific detail interviewer wants to consider in this service.

Tip 3 : Design your structure and functions according to the requirements and try to convey your thoughts properly to the interviewer so that you do not mess up while implementing the idea .

3. System Design Question

Implement a ctlr+f (find) functionality in a file.

Problem approach

Tip 1: Hash map can be used as a data structure to implement this functionality. According to the type of data stored in the file, a combination of data structures can be used to implement insert() and search() functionality.

Here's your problem of the day

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

Skill covered: Programming

How do you remove whitespace from the start of a string?

Choose another skill to practice
Similar interview experiences
company logo
Software Engineer
3 rounds | 5 problems
Interviewed by Housing.com
1361 views
0 comments
0 upvotes
company logo
Software Engineer
3 rounds | 8 problems
Interviewed by Housing.com
1509 views
0 comments
0 upvotes
company logo
Software Developer
3 rounds | 7 problems
Interviewed by Housing.com
1392 views
0 comments
0 upvotes
company logo
Lead Software Engineer
4 rounds | 4 problems
Interviewed by Housing.com
1250 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
Software Engineer
3 rounds | 7 problems
Interviewed by Optum
7976 views
1 comments
0 upvotes
company logo
Software Engineer
5 rounds | 5 problems
Interviewed by Microsoft
10148 views
1 comments
0 upvotes
company logo
Software Engineer
2 rounds | 4 problems
Interviewed by Amazon
4448 views
1 comments
0 upvotes