0% found this document useful (0 votes)
11 views13 pages

Juspay Round 1 & 2 Questions 2026

The document contains three programming questions related to algorithms and data structures, focusing on finding minimums of maximums in subarrays, counting leaf nodes in a tree with constraints on dangerous nodes, and managing a network of customers with bandwidth costs. Each question includes a problem statement, function signature, input/output format, and sample cases. Additionally, there are 16 follow-up questions covering various topics in computer science and mathematics.

Uploaded by

dhruvgoel0710
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views13 pages

Juspay Round 1 & 2 Questions 2026

The document contains three programming questions related to algorithms and data structures, focusing on finding minimums of maximums in subarrays, counting leaf nodes in a tree with constraints on dangerous nodes, and managing a network of customers with bandwidth costs. Each question includes a problem statement, function signature, input/output format, and sample cases. Additionally, there are 16 follow-up questions covering various topics in computer science and mathematics.

Uploaded by

dhruvgoel0710
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

JUSPAY ROUND 1 QUESTIONS

(3 Questions)
✅ QUESTION 1 — Weakest Peak (Sliding Window Minimum of
Maximums)

🧾 Problem Statement

You are given:

 An array closing_prices of size N

 Q queries

 Each query contains an integer h

For each query:

 Consider all subarrays of size h

 For each subarray, find its maximum

 Among all those maximums, return the minimum

Return a list of answers for all queries.

📥 Function Signature

public static List<Integer> solve(


int n,
int q,
List<Integer> closing_prices,
List<Integer> queries
)

📌 Input Format

1. First line → integer N

2. Second line → integer Q

3. Next N lines → elements of closing_prices

4. Next Q lines → window size h


📤 Output Format

Return a list of integers:


Each integer = minimum of maximums for that query.

📏 Constraints

1 ≤ N ≤ 10^5
1 ≤ Q ≤ 10^5
1 ≤ closing_prices[i] ≤ 10^9
1≤h≤N

🧪 Sample

Input

7
1
[97, 95, 93, 100, 98, 99, 94]
4

Process

Subarrays of size 4:

[97,95,93,100] → 100
[95,93,100,98] → 100
[93,100,98,99] → 100
[100,98,99,94] → 100

Minimum of maximums = 100

Output

100

✅ QUESTION 2 — Safe View Points (Kefa and Park Type)

🧾 Problem Statement

Sam wants to inspect outermost towers (leaf nodes).

Given:

 A tree of N nodes
 Root = node 1

 Arr1[i] = 1 → dangerous

 Arr1[i] = 0 → safe

 M = maximum allowed consecutive dangerous nodes

Count how many leaf nodes are reachable from root


such that no path contains more than M consecutive
dangerous nodes.

📥 Function Signature

public static int safeViewPoints(


int N,
int M,
int k,
List<Integer> Arr1,
List<List<Integer>> Arr2
)

📌 Input Format

1. N

2. M

3. k (always N-1)

4. Next N lines → Arr1[i]

5. Next k lines → edges

📤 Output

Single integer → number of valid leaf nodes.

📏 Constraints

2 ≤ N ≤ 10^5
1≤M≤N
k = N-1
1 ≤ Arr1[i] ≤ 1
1 ≤ edges[i][j] ≤ 10^5
🧪 Sample 1

Input

7
1
6
1
0
1
1
0
0
0
1 2
1 3
2 4
2 5
3 6
3 7

Output

🧠 Explanation

Only 2 leaf nodes satisfy consecutive ≤ 1.

✅ QUESTION 3 — Network Technician's Mission (Tree + Update +


Path Sum)
🧾 Problem Statement

You are managing a network of customers.

 Network forms a tree

 Each cable has bandwidth cost

 Two operations:

Type 1

1AB0

Find total bandwidth cost between A and B.

Type 2

2UVW

Update cost of cable between U and V to W.

Return sum of all type-1 query results.

📥 Function Signature

public static int solve(


int N,
int R,
int M,
List<List<Integer>> edges,
int Q,
List<List<Integer>> queries
)

📌 Input Format

1. N

2. R (root)

3. M (= N-1)

4. 3 (columns in edges)

5. M lines → U V W

6. Q
7. 4 (columns in queries)

8. Q lines → query

📤 Output

Return integer:
Sum of all type-1 query answers.

📏 Constraints

1 ≤ N ≤ 10^5
1 ≤ Q ≤ 10^5
1 ≤ edges[i][j] ≤ 10^5
1 ≤ queries[i][j] ≤ 10^5

🧪 Sample 1

Input

2
1
1
1 25
3
1 210
2 122
1 120

Explanation

Initial cost = 5
After update = 2

Total = 5 + 2 = 7

Output

🧪 Sample 2

Input
3
1
2
1 21
2 31
3
1 130
2 235
1 130

Explanation

Initial path 1→3 = 1+1 = 2


After update = 1+5 = 6

Total = 2 + 6 = 8

Output

🧪 Sample 3

Input

5
1
4
1 2 3
1 3 2
2 4 4
2 5 1
4
1 4 5 0
2 1 2 10
1 1 4 0
1 1 3 0

Output

21

JUSPAY Round 2 questions


(16 Questions)

1. Probability – Dice

Question:
Two dice are rolled and the sum is known to be at least 9. What is
the probability that the sum is exactly 9?

Answer:
1/3

2. Operating Systems – fork()

Question:
int ret1 = fork();
int ret2 = fork();
wait();

How many child processes are created?

Answer:
3 child processes

3. Server Load Redistribution

Question:
There are 100 servers each running at 10% CPU utilization.
20% of the servers fail.
The remaining servers handle the same total traffic.

What is the new CPU utilization per remaining server?

Options:

 20%

 12.50%

 25%

 17.50%

Answer:
12.50%
4. Context Switching (Single Core Machine)

Question:
In a single-core machine, when transitioning from Process 1 to
Process 2 during execution, which event typically triggers the
switch?

Options:

 Process 1 explicitly tells Process 2 to take over

 Process 1 is preempted by interrupt from Process 2

 Process 1 is preempted by a hardware interrupt (timer)

 Process 1 is swapped manually by user

Answer:
Process 1 is preempted by a hardware interrupt (timer)

5. Tree Data Structure

Question:
To efficiently maintain an ordered list of elements that frequently
changes due to insertions and deletions, what key characteristic
should the tree structure have?

Options:

 Ability to handle many elements per node

 Balanced height to ensure efficiency

 Quick access to minimum element

 Rotations based on access frequency

Answer:
Balanced height to ensure efficiency

6. Stack Use Cases


Question:
Which of the following are suitable use cases for a stack?

a) Checking balanced parentheses


b) Store least recently used memory address
c) Expression conversion
d) Transfer data between asynchronous processes

Options:

 a, b, c

 a, c

 c, d

 a, d

Answer:
a, c

7. DFS Traversal

Question:
Before making a recursive call in DFS, which condition should be
checked?

Options:

 !visited[i]

 visited[adj[v][i]] == false

 visited[adj[i][v]] == false

 adj[v][i] == visited

Answer:
visited[adj[v][i]] == false

8. Greedy Strategy (Knapsack)

Question:
To maximize shipment value within a fixed weight limit, what
strategy should be used?
Options:

 Select items with least weight first

 Select items with highest value first

 Select items with highest value-to-weight ratio

 Select items based on warehouse order

Answer:
Select items with highest value-to-weight ratio

9. BFS vs Dijkstra

Question:
In a graph where every edge weight is 1, why is BFS preferred
over Dijkstra’s algorithm for finding shortest paths from a
source?

Options:

 BFS has lower time complexity for uniform edge weights

 BFS can handle positive and negative weights

 BFS guarantees shortest path in weighted graphs

 Dijkstra is preferred because BFS gives incorrect results

Answer:
BFS has lower time complexity for uniform edge weights

10. Scheduling – SRTF (Preemptive)

Question:
Processes:

P1: Arrival 0, Burst 10


P2: Arrival 2, Burst 2
P3: Arrival 3, Burst 3

Using Shortest Remaining Time First (preemptive), find


completion times.

Options:

 P1 at 10, P2 at 4, P3 at 7

 P1 at 15, P2 at 12, P3 at 13
 P1 at 15, P2 at 4, P3 at 7

 P1 at 13, P2 at 12, P3 at 15

Answer:
P1 at 15, P2 at 4, P3 at 7

11. Concentric Trains Problem

Question:
Two trains move on concentric circular tracks of radius r1 and r2.
Both move at 10 m/s in the same direction.
How fast must you run (opposite to train direction) so you appear
stationary to a friend on the outer track?

Exact answer:
10/11 ≈ 0.91 m/s

Closest available option:


1.1 m/s

12. Inclined Plane + Spring + Wedge

Question:
A 5 kg block starts from rest at the top of a frictionless 30° incline
of length 10 m.
A spring of natural length 1 m and spring constant 200 N/m is
placed at the base.
The wedge is on a frictionless surface.
Take g = 10 m/s².

Find the maximum displacement of the block along the incline

13. A m=2 kgm = 2\,kgm=2kg block is initially at rest at


the top of a frictionless inclined plane of mass M=10 kgM =
10\,kgM=10kg.
The angle of inclination is θ=30∘\theta = 30^\circθ=30∘.
The total length of the incline is l1+l2=5 ml_1 + l_2 = 5\,ml1
+l2=5m.

The block slides down and compresses a spring of spring constant


k=200 N/mk = 200\,N/mk=200N/m placed at the bottom along the
incline.
The wedge is on a frictionless horizontal surface.
Take g=10 m/s2g = 10\,m/s^2g=10m/s2.

Question:

What is the maximum compression of the spring?

Options:

A) 0.50 m
B) 0.71 m
C) 0.76 m
D) 1.00 m

✅ Correct Answer: C) 0.76 m

You might also like