JP Morgan OA SWE 2024
Anonymous User
617

I have applied on JP Morgan's career portal and received hackerrank test link after 3 days. 2 questions to be solved in 60 mins.

Question 1:
Given an array of servers or nodes with security value, a hacker tries to hack the servers and gain maximum security value. Whenever a server is hacked, that server's security value is added to hacker's security value. Initially hacker starts with 0 security value. If hacker starts on ith node, next node he can jump to is i + k where k lies between 1 and n. Find the optimal start node from which the hacker can gain maximum security value and return the maximum security value.

Solution: Can be solved directly using two for loops.

Question 2:
Given an integer array, perform operations by selecting 2 elements from the array, sum them up and delete those two elements from the array and add the new sum to the array. Return the final sum.

Solution: Use a priorirty queue and add the sum to the queue and keep incrementing the sum and at the end when pq's size is 1 return the sum added till now.

Awaiting response from the recruiter.

Comments (4)