Panda Guru LogoPanda
Guru

SDE Intern Questions at Nuclues Teq

Round 1

Questions:

Q1. N-Closest Friend Sum

You have N friends. You want to party, however each house has a capacity of N-2. Return an array ARR such that ARR[i] = SUM(closest distance of friends (total N-2 friends) from House).

Ex - input1 = 4 = N, input2 = {1,3,8,10} Output = {9,7,7,9} Total No. of friends each house can contain = N-2 = 4-2 = 2 Iterating Input2: at i = 0, we can choose from {3,8,10} closest are 3-1 = 2, 8-1=7 ARR[i]=2+7=9 similarly at i=1, {1,8,10} Closest are 3-1 = 2 and 8-3=5 ARR[i] = 2 + 5 = 7 Same for all the elements so Output = {9,7,7,9}
Candidate's Approach
  1. For Each element find the distance from all other elements and push into Heap.
  2. Pop N-2 from Heap and SUM them.
  3. Append them in Answer Array.

Only passed 7/10 Test Cases. IDK what those 3 edge cases were.

Interviewer's Feedback

No feedback provided.


Q2. Transmission of Data

You are given N data packets (say DATA), before sending them they need to be encrypted. There are 2 operations you can perform, 'A' and 'B'. An Input array (say OPERATION) is Given which has the sequence of Operation to Perform. Another Input array (NOS) is given which tells the number of Elements you need to perform the operation on. Another Input Array (say KEY) is given which has the KEY for ith Operation. You are required to return the Encrypted Data Packet.

Operation A:

index = index of current Operation value = current value from DATA key = KEY[index] for (i=0 to i = NOS[index]): value = DATA[i] DATA[i] = XOR(value, key)

Operation B:

index = index of current Operation value = current value from DATA key = KEY[index] for (i=Size(Data)-1 to i = NOS[index]): value = DATA[i] DATA[i] = XOR(value, key)

Inputs: N = No of Data
DATA = Array of Data
OPERATION = Array of Operation
NOS = Array of No. of Elements to perform on.
KEY = Array of Encryption Key

Output: Encrypted Data Array

Example - N = 4 DATA = {1,2,3,4} OPERATION = {'A','B'} NOS = {3,1} KEY = {5,10} First Iteration of Operation: i=0, OPERATION[0] = 'A' A - XOR from first to NOS[I] = NOS[0] = 3 key = KEY[I]= KEY[0]=5 DATA = {1,2,3,4} < OLD DATA = {4,7,6,4} < NEW Second Iteration : i= 1, B - XOR from Size-1 to only NOS[i] elements key=KEY[i]=10 DATA = {4,7,6,4} < OLD DATA = {4,7,6,14} < NEW Final Answer = {4,7,6,14}
Candidate's Approach

Iterate through the operations using, get the key=KEY[i], count=Nos[i], and do a While loop for each operation until count is 0.

Only passed 3/10 cases.

Interviewer's Feedback

No feedback provided.


Q3. SQL

Return registration_id, course_name, and room_number from the given schema. The Schema had 7 tables in total, all Linked via Foreign keys, you could understand the complexity.

Note: No specific approach or feedback provided for this question.