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

Software Developer

UHG
upvote
share-icon
3 rounds | 5 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 5 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 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.

Interview rounds

01
Round
Medium
Coding Test - Pen and paper
Duration60 minutes
Interview date25 May 2015
Coding problem0

This was the first round which was a MCQ round.

Output based, aptitude based questions, OOPS, DBMS, OS questions were asked.

02
Round
Medium
Coding Test - Pen and paper
Duration60 minutes
Interview date25 May 2015
Coding problem3

This was the second test round which had 3 sections. 
First section consisted of technical MCQs. Second section contained three coding problems of easy difficulty level. Third section had 2 networking questions for which the answers had to be written in detail.

1. Largest Tree Value

Moderate
25m average time
75% success
0/80
Asked in companies
FacebookAppleSamsung

You have been given the ‘ROOT’ of a binary tree having ‘N’ nodes, you need to find the largest value in each row or level of the binary tree.

For Example

Tree

For the above binary tree, 
Max value at level 0 = 6.
Max value at level 1 = max(9 , 3) = 9
Max value at level 2 = max (4, 8, 2) = 8
Problem approach

Every node has to be visited to figure out the maximum. So the idea is to traverse the given tree and for every node return maximum of 3 values. 

1. Node’s data.
2. Maximum in node’s left subtree.
3. Maximum in node’s right subtree.

Pseudocode :
findMax(Node root)
{
// Base case
if (root is NULL)
return INT_MIN;

// Return maximum of 3 values:
// 1) Root's data 2) Max in Left Subtree 3) Max in right subtree
res = root->data;
lres = findMax(root->left);
rres = findMax(root->right);
if (lres > res)
res = lres;
if (rres > res)
res = rres;
return res;
}

Try solving now

2. Equilibrium Index

Easy
0/40
Asked in companies
Expedia GroupCoinbaseGoldman Sachs

You are given an array Arr consisting of N integers. You need to find the equilibrium index of the array.

An index is considered as an equilibrium index if the sum of elements of the array to the left of that index is equal to the sum of elements to the right of it.

Note:

1. The array follows 0-based indexing, so you need to return the 0-based index of the element.
2. Note that the element at the equilibrium index won’t be considered for either left sum or right sum.
3. If there are multiple indices which satisfy the given condition, then return the left-most index i.e if there are indices i,j,k…. which are equilibrium indices, return the minimum among them
4. If no such index is present in the array, return -1.
Problem approach

The direct approach would be to use two loops. Outer loop iterates through all the element and inner loop finds out whether the current index picked by the outer loop is equilibrium index or not. Time complexity of this solution is O(n^2).

There is an efficient approach which can solve this problem in O(n) time complexity. The idea is to get the total sum of the array first. Then Iterate through the array and keep updating the left sum which is initialized as zero. In the loop, we can get the right sum by subtracting the elements one by one.
Algorithm : 
1) Initialize leftsum as 0
2) Get the total sum of the array as sum
3) Iterate through the array and for each index i, do following.
a) Update sum to get the right sum. 
sum = sum - arr[i] 
// sum is now right sum
b) If leftsum is equal to sum, then return current index. 
// update leftsum for next iteration.
c) leftsum = leftsum + arr[i]
4) return -1 
// If we come out of loop without returning then there is no equilibrium index

Try solving now

3. Queue Using Stack

Moderate
30m average time
60% success
0/80
Asked in companies
GE (General Electric)ZSGoldman Sachs

Implement a queue data structure which follows FIFO(First In First Out) property, using only the instances of the stack data structure.


Note:
1. To implement means you need to complete some predefined functions, which are supported by a normal queue such that it can efficiently handle the given input queries which are defined below.


2. The implemented queue must support the following operations of a normal queue: 

a. enQueue(data) : This function should take one argument of type integer and place the integer to the back of the queue.

b. deQueue(): This function should remove an integer from the front of the queue and also return that integer. If the queue is empty, it should return -1.

c. peek(): This function returns the element present in the front of the queue. If the queue is empty, it should return -1.

d. isEmpty(): This function should return true if the queue is empty and false otherwise.


3. You will be given q queries of 4 types:

a. 1 val - For this type of query, you need to insert the integer val to the back of the queue.

b. 2 - For this type of query, you need to remove the element from the front of the queue, and also return it.

c. 3 - For this type of query, you need to return the element present at the front of the queue(No need to remove it from the queue).

d. 4 - For this type of query, you need to return true if the queue is empty and false otherwise.


4. For every query of type:

a. 1, you do not need to return anything.

b. 2, return the integer being deQueued from the queue.

c. 3, return the integer present in the front of the queue.

d. 4, return “true” if the queue is empty, “false” otherwise.
Example
Operations: 
1 5
1 10
2
3
4

Enqueue operation 1 5: We insert 5 at the back of the queue.
Queue: [5]

Enqueue operation 1 10: We insert 10 at the back of the queue.
Queue: [5, 10]

Dequeue operation 2: We remove the element from the front of the queue, which is 5, and print it.
Output: 5
Queue: [10]

Peek operation 3: We return the element present at the front of the queue, which is 10, without removing it.
Output: 10
Queue: [10]

IsEmpty operation 4: We check if the queue is empty.
Output: False
Queue: [10]
Problem approach

One method could be to make the enQueue operation costly. This method makes sure that oldest entered element is always at the top of stack 1, so that deQueue operation just pops from stack1. To put the element at top of stack1, stack2 is used.

enQueue(q, x): 
While stack1 is not empty, push everything from stack1 to stack2.
Push x to stack1 (assuming size of stacks is unlimited).
Push everything back to stack1.
Here time complexity will be O(n)

deQueue(q): 
If stack1 is empty then error
Pop an item from stack1 and return it
Here time complexity will be O(1)

Try solving now
03
Round
Medium
Face to Face
Duration60 minutes
Interview date25 May 2015
Coding problem2

Technical Interview round with questions on DSA.

1. Maximum Area Square

Moderate
10m average time
90% success
0/80
Asked in companies
Urban Company (UrbanClap)FreshworksBNY Mellon

You have been given a non-empty grid ‘MAT’ consisting of only 0s and 1s. Your task is to find the area of maximum size square sub-matrix with all 1s.

If there is no such sub-matrix, print 0.

For example, for the following grid:

Input

The area of the largest square submatrix with all 1s is 4.
Try solving now

2. Wildcard Pattern Matching

Hard
50m average time
30% success
0/120
Asked in companies
FreshworksWalmartSamsung R&D Institute

Given a text and a wildcard pattern of size N and M respectively, implement a wildcard pattern matching algorithm that finds if the wildcard pattern is matched with the text. The matching should cover the entire text not partial text.

The wildcard pattern can include the characters ‘?’ and ‘*’

 ‘?’ – matches any single character 
 ‘*’ – Matches any sequence of characters(sequence can be of length 0 or more)
Problem approach

Let’s consider any character in the pattern : 

Case 1: The character is ‘*’ 
Here two cases arise:
a. We can ignore ‘*’ character and move to next character in the Pattern.
b. ‘*’ character matches with one or more characters in Text. Here we will move to next character in the string.

Case 2: The character is ‘?’ 
We can ignore current character in Text and move to next character in the Pattern and Text.

Case 3: The character is not a wildcard character 
If current character in Text matches with current character in Pattern, we move to next character in the Pattern and Text. If they do not match, wildcard pattern and Text do not match.

This can be solved using Dynamic Programming. Let T[i][j] is true if first i characters in given string matches the first j characters of pattern.

Algorithm :

DP Initialization: 
// both text and pattern are null
T[0][0] = true; 

// pattern is null
T[i][0] = false; 

// text is null
T[0][j] = T[0][j - 1] if pattern[j – 1] is '*' 

DP relation : 
// If current characters match, result is same as result for lengths minus one. Characters match in two cases:
// a) If pattern character is '?' then it matches with any character of text. 
// b) If current characters in both match
if ( pattern[j – 1] == ‘?’) || 
(pattern[j – 1] == text[i - 1])
T[i][j] = T[i-1][j-1] 

// If we encounter ‘*’, two choices are possible-
// a) We ignore ‘*’ character and move to next character in the pattern, i.e., ‘*’ indicates an empty sequence.
// b) '*' character matches with ith character in input 
else if (pattern[j – 1] == ‘*’)
T[i][j] = T[i][j-1] || T[i-1][j] 

else // if (pattern[j – 1] != text[i - 1])
T[i][j] = false

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

What is recursion?

Choose another skill to practice
Similar interview experiences
SDE - Intern
3 rounds | 4 problems
Interviewed by UHG
1047 views
0 comments
0 upvotes
SDE - 1
3 rounds | 11 problems
Interviewed by UHG
1558 views
0 comments
0 upvotes
SDE - Intern
3 rounds | 4 problems
Interviewed by UHG
1041 views
0 comments
0 upvotes
SDE - 1
4 rounds | 4 problems
Interviewed by UHG
926 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
Software Developer
5 rounds | 14 problems
Interviewed by Microsoft
3931 views
1 comments
0 upvotes
company logo
Software Developer
6 rounds | 12 problems
Interviewed by SAP Labs
2806 views
0 comments
0 upvotes
company logo
Software Developer
3 rounds | 3 problems
Interviewed by Amazon
1133 views
0 comments
0 upvotes