Josh Technology Group interview experience Real time questions & tips from candidates to crack your interview

SDE - 1

Josh Technology Group
upvote
share-icon
6 rounds | 14 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 2.5 Months
Topics: Data Structures, Algorithms, OOPS, DBMS, Pointers
Tip
Tip

Tip 1 : Be consistent
Tip 2 : Try interacting with the interviewer by sharing your approach to them
Tip 3 : Practice mostly asked DSA questions
Tip 4 : Always know the time complexity of your solution and try optimising your approach.
Tip 5 : Focus on building the logic instead of just cramming the solution.

Application process
Where: Campus
Eligibility: No criteria
Resume Tip
Resume tip

Tip 1 : Do not put false things on resume
Tip 2 : Keep it short and simple

Interview rounds

02
Round
Medium
Online Coding Test
Duration70 Minutes
Interview date12 Aug 2021
Coding problem3

Timing was 1:00 PM. There were total 4 questions out of which 3 were coding questions and one was pointer based output question.

1. Remove Duplicates From Unsorted Linked List

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

You are given a linked list of N nodes. Your task is to remove the duplicate nodes from the linked list such that every element in the linked list occurs only once i.e. in case an element occurs more than once, only keep its first occurrence in the list.

For example :
Assuming the linked list is 3 -> 2 -> 3 -> 4 -> 2 -> 3 -> NULL.

Number ‘2’ and ‘3’ occurs more than once. Hence we remove the duplicates and keep only their first occurrence. So, our list becomes : 3 -> 2 -> 4 -> NULL.
Problem approach

As the list was sorted so i used two pointer approach.
Eg: 1->2->2->3
p1=1 and p2=2 as the value of p1 and p2 is different so moving both the pointers.
p1=2 and p2=2 as the value of both the pointers are same so moving moving p2.
p1=2 and p2=3 as the value of p1 and p2 is different so now changing next of p1 to point to p2 and moving both the pointers. 
p1=3 and p2=null as p2 becomes null so terminating the loop

Try solving now

2. Squares of a Sorted Array

Easy
15m average time
85% success
0/40
Asked in companies
Natwest GroupAdobeAmazon

You are given an array/list ‘ARR’ of ‘N’ integers. You have to generate an array/list containing squares of each number in ‘ARR’, sorted in increasing order.

For example :

Input:
‘ARR’ = [-6,-3, 2, 1, 5] 

If we take a square of each element then the array/list will become [36, 9, 4, 1, 25].
Then the sorted array/list will be [1, 4, 9, 25, 36].

Output :
[1, 4, 9, 25, 36].
Problem approach

as the array was sorted so i used two pointer approach.
Eg: [-6,-1,5]
p1=-6 and p2=5 and result=[ , , ] so comparing p1 and p2 without including sign so p1 is greater so storing square of p1 in the result and moving p1 to next.
now p1=-1 and p2=5 and result=[ , ,36] so comparing p1 and p2 without including sign so p2 is greater so storing square of p2 in the result and moving p2 to prev.
now p1=-1 and p2=-1 and result=[ ,25,36] so comparing p1 and p2 without including sign so both are equal so storing square of p1 and moving p1 to next.
now p1=5 and p2=-1 and result=[1,25,36] as our pointers crossed each other or we can say our resultant array is filled so returning the result.

Try solving now

3. Sum root to leaf

Easy
10m average time
90% success
0/40
Asked in companies
MicrosoftUnacademyMorgan Stanley

You are given an arbitrary binary tree consisting of N nodes where each node is associated with a certain integer value from 1 to 9. Consider each root to leaf path as a number.

For example:

       1
      /  \
     2    3

The root to leaf path 1->2 represents the number 12.
The root to leaf path 1->3 represents the number 13.

Your task is to find the total sum of all the possible root to leaf paths.

In the above example,

The total sum of all the possible root to leaf paths is 12+13 = 25
Note:
The output may be very large, return the answer after taking modulus with (10^9+7).
Problem approach

In this I used inorder traversal using recursion. Take a variable say v=0 at root. Now at each level multiple the value received by 10 and add the current nodes value. Repeat the same until reach the leaf node. When reach the leaf node add the currently formed value in the result.
Eg: 
6
/ \ 
2 4
/ \ \ 
5 3 8
here v=0 at root(6) and result=0
now multiply v to 10 add current nodes value (root node=6) and pass to next level.
value received at 2nd level is 6. Multiply v to 10 add current nodes value (left node=2) and pass to next level.
value received for left sub tree (below 2) is 62. Multiply v to 10 add current nodes value (left node=5), v=625. As this is leaf node add this value to result.
And moving back to 2nd level and going to right sub tree of 2 value received is 62. Multiply v to 10 add current nodes value (right node=3), v=623. As this is leaf node add this value to result.
And so on for right sub tree of 6

Try solving now
03
Round
Medium
Coding Test - Pen and paper
Duration85 Minutes
Interview date12 May 2022
Coding problem4

Timing was 4:00 PM. There were total 4 questions all questions were coding questions.

1. First non repeating character

Easy
15m average time
80% success
0/40
Asked in companies
QuikrHCL TechnologiesMakeMyTrip

Ninja is now bored with numbers and is now playing with characters but hates when he gets repeated characters. Ninja is provided a string, and he wants to return the first unique character in the string.The string will contain characters only from the English alphabet set, i.e., ('A' - 'Z') and ('a' - 'z'). If there is no non-repeating character, print the first character of the string. If there is no non-repeating character, return the first character of the string.

Try solving now

2. Chocolate Problem

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

Given an array/list of integer numbers 'CHOCOLATES' of size 'N', where each value of the array/list represents the number of chocolates in the packet. There are ‘M’ number of students and the task is to distribute the chocolate to their students. Distribute chocolate in such a way that:

1. Each student gets at least one packet of chocolate.

2. The difference between the maximum number of chocolate in a packet and the minimum number of chocolate in a packet given to the students is minimum.

Example :

Given 'N' : 5 (number of packets) and 'M' : 3 (number of students)

subsequence

And chocolates in each packet is : {8, 11, 7, 15, 2}

All possible way to distribute 5 packets of chocolates among 3 students are -

( 8,15, 7 ) difference of maximum-minimum is ‘15 - 7’ = ‘8’
( 8, 15, 2 ) difference of maximum-minimum is ‘15 - 2’ = ‘13’ 
( 8, 15, 11 ) difference of maximum-minimum is ‘15 - 8’ = ‘7’
( 8, 7, 2 ) difference of maximum-minimum is ‘8 - 2’ = ‘6’
( 8, 7, 11 ) difference of maximum-minimum is ‘11 - 7’ = ‘4’
( 8, 2, 11 ) difference of maximum-minimum is ‘11 - 2’ = ‘9’
( 15, 7, 2 ) difference of maximum-minimum is ‘15 - 2’ = 13’
( 15, 7, 11 ) difference of maximum-minimum is ‘15 - 7’ = ‘8’
( 15, 2, 11 ) difference of maximum-minimum is ‘15 - 2’ = ‘13’
( 7, 2, 11 ) difference of maximum-minimum is ‘11 - 2’ = ‘9’

Hence there are 10 possible ways to distribute ‘5’ packets of chocolate among the ‘3’ students and difference of combination (8, 7, 11) is ‘maximum - minimum’ = ‘11 - 7’ = ‘4’ is minimum in all of the above.
Try solving now

3. Check If Linked List Is Palindrome

Easy
15m average time
85% success
0/40
Asked in companies
HSBCAmazonThought Works

You are given a Singly Linked List of integers. You have to return true if the linked list is palindrome, else return false.


A Linked List is a palindrome if it reads the same from left to right and from right to left.


Example:
The lists (1 -> 2 -> 1), (3 -> 4 -> 4-> 3), and (1) are palindromes, while the lists (1 -> 2 -> 3) and (3 -> 4) are not.
Problem approach

The second method used in this article can be used here. First we will reverse the second half
of the list and then we will have two pointers. First pointing to the head of the given list and
second point to the head of the linked list we reversed. Now we just need to merge the two lists
by changing their pointers alternatively.
Like in this case first our given list is 1->2->3->4->5->6->7->8
Now we reverse the 2nd half of the list and we have 2 lists as 1->2->3->4 and 8->7->6->5
Now we just need to traverse the list one by one and change their pointers.
You can use
Method 2  to find the middle element of the linked list and by storing the previous
element to mid you can make the next pointer of the previous element to mid to null. So there
will be no loops in the list after we reverse the second half and it will be much easier to traverse
both the lists.

Try solving now

4. Convert a binary tree to its sum tree

Easy
15m average time
85% success
0/40
Asked in companies
AmazonMicrosoftSamsung

Given a binary tree of integers, you are supposed to modify the given binary tree to a sum tree where each node value is replaced by the sum of the values of both left and right subtrees in the given tree. The value of leaf nodes is changed to zero.

Example:
Below is the example showing the input tree and its sum tree.  

alt text

Problem approach

We will use BFS here and a variable l which will determine the level that we are traversing
and a sum variable that will store the sum of each level. Now here we have to consider that the
first 2 levels are always in AP.
So as AP is defined as a,a+d,a+2d,a+3d…….
When l=0 that is when we are at the root node we will store this value in a variable named ‘a’
and for this level we will store 0 in the resultant list/vector. Then when we are at l=1 that is level
1 we will store the sum of nodes at this level in the variable sum and (sum-a) into a variable
named ‘d’ and for this level we will store 0 in the resultant list/vector. Now when we are at l=2
that is at level 2 we will evaluate the sum of nodes at this level and store it in the variable sum
and from now on we will store ((a+(l*d)-sum) into resultant list/vector.

Try solving now
04
Round
Medium
Face to Face
Duration75 Minutes
Interview date19 Aug 2022
Coding problem2

Timing was 10:00 AM. There were 4 rounds scheduled for one single day. There 3 technical interview and 1 HR. There were 2 question in each Technical interview.

1. Reverse a Sublist of Linked List

Easy
10m average time
90% success
0/40
Asked in companies
HSBCFacebookLiberin Technologies

You are given a linked list of 'N' nodes. Your task is to reverse the linked list from position 'X' to 'Y'.

For example:
Assuming, the linked list is 10 -> 20 -> 30 -> 40 -> 50 -> 60 -> NULL. X = 2 and Y = 5. On reversing the given linked list from position 2 to 5, we get 10 -> 50 -> 40 -> 30 -> 20 -> 60 -> NULL.
Problem approach

For rotating the given sublist that extends from m to n element, move the list from (n-k+1)th to nth node to starting of sub-list to finish the rotation. 
If k is greater than size of sublist then we will take its modulo with size of sublist. So traverse through list using a pointer and a counter and we will save (m-1)th node and later make it point to (n-k+1)th node and hence bring (n-k+1)th node to the start(front) of sublist. 
Similarly we will save mth node and later make nth node point to it. And for keeping rest of list intact we will make (n-k)th node point to next node of n (maybe NULL). And finally we will get the k times right rotated sublist.

Try solving now

2. Reverse Level Order Traversal

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

You have been given a Binary Tree of integers. You are supposed to return the reverse of the level order traversal.

For example:
For the given binary tree

Example

The reverse level order traversal will be {7,6,5,4,3,2,1}.
Try solving now
05
Round
Easy
Face to Face
Duration95 Minutes
Interview date19 Aug 2021
Coding problem2

Timing was 1:00 PM.

1. Merge Two Sorted Linked Lists

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

You are given two sorted linked lists. You have to merge them to produce a combined sorted linked list. You need to return the head of the final linked list.

Note:

The given linked lists may or may not be null.

For example:

If the first list is: 1 -> 4 -> 5 -> NULL and the second list is: 2 -> 3 -> 5 -> NULL

The final list would be: 1 -> 2 -> 3 -> 4 -> 5 -> 5 -> NULL
Problem approach

1. Start with head of both linked lists and find first common node. Use merging technique of sorted linked list for that. 
2. Keep track of sum of the elements too while doing this and set head of result list based on greater sum till first common node. 
3. After this till the current pointers of both lists don’t become NULL we need to adjust the next of prev pointers based on greater sum.

Try solving now

2. Closest Leaf To Given Node In Binary Tree

Moderate
15m average time
85% success
0/80
Asked in companies
Cerner CorporationJosh Technology GroupGoDigitley

Ninja is stuck in a maze which is in a form of a binary tree. He needs your help in order to get out.

Ninja is presently at the node ‘X’. The only exit points of the maze are the leaf nodes of the tree. You need to tell him the distance to the nearest exit point from his current location. This will help him decide which path he should take in order to escape from the maze.

Example:

sample tree 1

Suppose, Ninja is stuck at node 62. The possible exit points in the maze are: 40, 10, and 20. From all the possible exit points the closest ones are 10 and 20 which are at a distance of 1 unit.
Problem approach

My approach to this question was that first we can find if the node is in right subtree or left
subtree and store the the length of root to leaf of the other side of the tree.( If the given node lies
in the left sub tree simply store the maximum root to leaf path of right side and vice versa).
Second we need to calculate the length of path from root to given node.
Third we need to get the maximum distance of leaf nodes from the given node. (leaf nodes
under the given node).
Now we have 3 distances:
First: maximum distance of root to leaf node of other side
Second: distance of given node to root node
Third: maximum distance of given node to leaf node under given node
Now we can simply return max((first+second),third)
In the given example our given node lies in the right side of the given tree so values of
first=2
second=1
third=1
And the max of first+second and third is 3. So 3 is the answer
We can calculate first and second in single traversal and as we are given the node and not just
the value we can directly calculate third by using a simple recursive function.

Try solving now
06
Round
Easy
Face to Face
Duration180 Minutes
Interview date19 Aug 2021
Coding problem2

Timing was 4:30 PM

1. Make Sum Divisible By P

Moderate
20m average time
80% success
0/80
Asked in companies
Saas labsalibabaJosh Technology Group

You are given an array/list of positive integers ‘NUMS’ of size 'N' and positive integer 'P'. You need to remove the smallest subarray (possibly empty) such that the sum of the remaining elements is divisible by ‘P’.

Your task is to print the length of the smallest subarray that you need to remove, or -1 if it's impossible.

Note:

1. It is not allowed to remove the whole array.
2. A subarray is defined as a contiguous block of elements in the array.
Example:
Suppose given ‘NUMS’ is [3, 1, 4, 2] and ‘P’ is 6.
The sum of the elements in ‘NUMS’ is 10, which is not divisible by 6. We can remove the subarray [4], and the sum of the remaining elements is 6, which is divisible by 6.
So print ‘1’ as a length of the removed subarray [4].
Try solving now
Hard
20m average time
80% success
0/120
Asked in companies
Goldman SachsUberApple

You are given an arbitrary binary tree, a node of the tree, and an integer 'K'. You need to find all such nodes which have a distance K from the given node and return the list of these nodes.


Distance between two nodes in a binary tree is defined as the number of connections/edges in the path between the two nodes.


Note:

1. A binary tree is a tree in which each node has at most two children. 
2. The given tree will be non-empty.
3. The given tree can have multiple nodes with the same value.
4. If there are no nodes in the tree which are at distance = K from the given node, return an empty list.
5. You can return the list of values of valid nodes in any order. For example if the valid nodes have values 1,2,3, then you can return {1,2,3} or {3,1,2} etc.
Example :

Sample Output 2 explanation

Consider this tree above. The target node is 5 and K = 3. The nodes at distance 1 from node 5 are {2}, nodes at distance 2 from node 5 are {1, 4} and nodes at distance 3 from node 5 are {6, 3}.
Try solving now
07
Round
Easy
HR Round
Duration15 Minutes
Interview date19 Aug 2021
Coding problem1

Timing of round was 8:30 PM

1. Basic HR Questions

They asked me about my project. They asked some other questions like what I knew about the company, can I work extra hours like 10-12hrs, whether i have short temper, how will manage to travel to gurugram, etc.

Problem approach

Tip 1 : Be honest for every answer.
Tip 2 : Do study about the company beforehand.

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
SDE - 1
3 rounds | 6 problems
Interviewed by Josh Technology Group
1521 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 6 problems
Interviewed by Josh Technology Group
1027 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 3 problems
Interviewed by Josh Technology Group
1485 views
0 comments
0 upvotes
company logo
SDE - 1
4 rounds | 7 problems
Interviewed by Josh Technology Group
1159 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
2 rounds | 3 problems
Interviewed by BNY Mellon
6365 views
3 comments
0 upvotes
company logo
SDE - 1
3 rounds | 6 problems
Interviewed by BNY Mellon
0 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 5 problems
Interviewed by CIS - Cyber Infrastructure
2197 views
0 comments
0 upvotes