Swiggy Online Assessment Questions SDE II
Anonymous User
7023

1. Swiggy Pantry - Knight Moves

At Swiggy, people tend to move diagonally instead of straight line as moving straight is too mainstream. Every floor in Swiggy office is an infinite canvas, where you can only move diagonally. In one move you can take multiple steps i.e you can jump more than one cell on the two dimensional grid. The move is considered to be a single move unless you take a turn where the # of moves is increased by 1(whenever you change your direction). Calculate the minimum number of moves required to reach pantry from your cubicle.
 

Input Format:

First line has integer T, the number of test cases

In each test case first line contains integer N

Next line contains 4 integers a,b,c,d first two are the co-ordinates of source(your cubicle) and the next two are co-ordinates of destination(pantry)

Output Format:

Print the minimum number of moves.

If you can’t reach print -1

Constraints

1 <= T <=10

1 <=  N <= 10^18

1 <= a , b , c , d <= N
 

Sample Input:

1

4

1 1 3 3

 

Sample Output:

1

image



---

2. Swiggy's Archery Game

In Swiggy archery game takes place in a square grid, where the balloons are kept in the cells of the square grid . Whenever a player shoots the arrow it bursts all the balloons on its path. The players can shoot from any side (only vertically and horizontally) which is outside the square grid arena . Calculate the minimum number of arrows required to burst all the balloons in the arena. Moving across the boundary of the grid is instantaneous and takes no time.

 

Input Format:

The first line contains T the number of test cases. The first line of each test case contains N the number of cells where balloons are present. The following N lines contain two integers X and Y each describing the index of the cell in which  balloons are present.
 

Output Format:

For each case print the minimum arrows required to burst all balloons.
 

Constraints:

1 ≤ T ≤ 10

1 ≤ N ≤ 50

0 ≤ X, Y ≤ (10^9)-1


Sample Input:

1
4
0 2
1 0
1 1
1 2
 

Sample Output:

2


Explanation:

Go  to row 0 and shoots an arrow towards right bursting balloon at index(0,2) then go to next row which is incredibly fast !! . From next row 1 shoot another arrow and burst all the balloons at index (1,0) (1,1) and (1,2)
 

image



---

3. Swiggy's Debrief Discussion

Problem Statment:
In Swiggy post taking interviews of candidates, there happens a de-brief session, where people sit around round tables and discuss interview's results.
During early startup period there were around N core team members who used to take interviews. This is how they used to split up and discuss:
1. They always used to split into 2 groups (each containing N/2 members)
2. Each group sits around a round table

Your task is to compute the number of distinct ways in which these N core team members can sit and discuss. Its always guaranteed N is an even number.
Note: If configuration of 4 persons sitting around one table is [1,2,3,4]
Other configurations like : [2,3,4,1], [3,4,1,2] are equal and should not be considered different.

Input Format:
You will be given a single integer N

Output Format:
Print a single line as output representing the answer to the problem.

Sample Input 0:
2
Sample Output 0:
1

Sample Input 1:
4
Sample Output 1:
3

Constraints:
2 <= N <= 20 
N is an even number for proper division into 2 groups

image

Comments (7)