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

SDE - 1

JUSPAY
upvote
share-icon
2 rounds | 3 Coding problems

Interview preparation journey

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

Tip 1 : Do some projects
Tip 2 : Be good in data structure

Application process
Where: Referral
Eligibility: 7 CGPA
Resume Tip
Resume tip

Tip 1 : Keep it short
Tip 2 : Don't try to add false things.

Interview rounds

01
Round
Easy
Online Coding Interview
Duration120 minutes
Interview date9 Nov 2022
Coding problem2

There were basically 2 questions asked on graph data structure and were quite challenging.
One problem was easy and the rest two were medium.
A basic understanding of graph traversal would suffice to clear this round.
The total mark allocated was 300 out of which I scored around 270 so I qualified for the next round.

1. Rat In A Maze

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

You are given a starting position for a rat which is stuck in a maze at an initial point (0, 0) (the maze can be thought of as a 2-dimensional plane). The maze would be given in the form of a square matrix of order 'N' * 'N' where the cells with value 0 represent the maze’s blocked locations while value 1 is the open/available path that the rat can take to reach its destination. The rat's destination is at ('N' - 1, 'N' - 1). Your task is to find all the possible paths that the rat can take to reach from source to destination in the maze. The possible directions that it can take to move in the maze are 'U'(up) i.e. (x, y - 1) , 'D'(down) i.e. (x, y + 1) , 'L' (left) i.e. (x - 1, y), 'R' (right) i.e. (x + 1, y).

Note:
Here, sorted paths mean that the expected output should be in alphabetical order.
For Example:
Given a square matrix of size 4*4 (i.e. here 'N' = 4):
1 0 0 0
1 1 0 0
1 1 0 0
0 1 1 1 
Expected Output:
DDRDRR DRDDRR 
i.e. Path-1: DDRDRR and Path-2: DRDDRR

The rat can reach the destination at (3, 3) from (0, 0) by two paths, i.e. DRDDRR and DDRDRR when printed in sorted order, we get DDRDRR DRDDRR.
Problem approach

The idea is to do a depth-first search to find all the cycles which are formed and calculate the length of the largest cycle. We are treating the array as a graph of directed edges. Whenever we get into any of the cells in the cycle, using dfs we will visit all the subsequent cells in the cycle. Out of all the cycles, we will return the cycle of maximum length.

The steps are as follows:

Initialize a boolean array ‘visited’ of size N with 0 at all the indexes initially which denotes whether a particular cell is visited or not.
Initialize an integer ‘res’ to 0, which denotes the largest cycle in the maze.
Define a recursive function ‘dfs’ with arguments ‘arr’, ‘positions’, ‘currentCell’, ‘totalLengthCovered’, array ‘visited’, an integer ‘res’ which denotes the given array ‘arr’, a hash map which is used to store the order in which vertices are visited, the current cell for the recursive call, the total number of cells visited in the current recursive call, array to know whether a particular cell is visited or not, and final answer ‘res’.
If the current cell is already visited in any of the previous recursive calls, then return from the function.
If there is no exit from the current cell, then mark the cell as visited and return from the function.
If the current cell is visited in the same recursive call i.e. it is present in the hash map, mark it as visited, take ‘res’ as a maximum of ‘res’ and ‘totalLengthCovered’ - positions[i].
Insert current cell into the hash map (current cell as the key and total length covered in the current recursion as the value).
Recursively call for the connected cell to the current cell and increment the total length covered.
After the recursive call, mark the current cell visited in the array ‘visited’.
Iterate from i = 0 to N-1:
If the ith cell is not visited:
Declare a hash map ‘positions’ that is used to store the order in which the vertices are visited.
Call the recursive function ‘dfs’ with arguments ‘arr’, ‘positions’, ‘i’, 0, ‘visited’, ‘res’.
If ‘res’ is equal to 0, it means that there is no cycle, return -1.
Otherwise, return ‘res’ as the final answer.

Try solving now

2. Colour The Graph

Moderate
20m average time
80% success
0/80
Asked in companies
MeeshoChegg Inc.Microsoft

You are given a graph with 'N' vertices numbered from '1' to 'N' and 'M' edges. You have to colour this graph in two different colours, say blue and red such that no two vertices connected by an edge are of the same colour.

Note :
The given graph may have connected components.
Try solving now
02
Round
Hard
Online Coding Test
Duration180 minutes
Interview date18 Nov 2022
Coding problem1

1. Trim spaces

Easy
0/40
Asked in company
JUSPAY

Given an input string S that contains multiple words, you need to remove all the spaces present in the input string.

There can be multiple spaces present after any word.

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
company logo
SDE - 1
2 rounds | 1 problems
Interviewed by JUSPAY
2399 views
0 comments
0 upvotes
company logo
SDE - 1
1 rounds | 2 problems
Interviewed by JUSPAY
2908 views
0 comments
0 upvotes
company logo
SDE - 1
1 rounds | 1 problems
Interviewed by JUSPAY
4912 views
0 comments
0 upvotes
company logo
SDE - 1
2 rounds | 4 problems
Interviewed by JUSPAY
2181 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
114579 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
57825 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
34961 views
7 comments
0 upvotes