Question: WayFair backend dev OA(Online assessment) questions | 26oct 2025 | Array Game (Wael and Aws) | Linked List Deletion (Multiple Choice)
0
Entering edit mode

Problem 1: Array Game (Wael and Aws)

Problem Description: Two players, Wael and Aws, are playing a game using two arrays, A and B, both of size N. The game consists of N/2 turns. In each turn:

  1. Wael picks two different unused indexes i and j.
  2. Aws picks one of them (either i or j). Let us call the index he chooses x. Aws then adds B[x] to his score.
  3. Let the other index be y. Wael adds A[y] to his score.

Objectives:

  • Wael wants to maximize the difference between his score and Aws's score at the end of the game.
  • Aws only cares about maximizing his own score.

Task: Find the final difference between the scores of Aws and Wael if both of them play optimally. Since the final answer may be very large, return it modulo 10^9+7.

Notes:

  • ONLY the final answer should be taken modulo 10^9+7.

Function Description: Complete the getOptimal function which takes the necessary parameters (likely the integer N and the two arrays A and B).

Generated Example & Test Case

Since the image didn't provide a sample input/output, here is a logical test case based on the rules:

Test Input:

N = 4

A = [5, 2, 8, 9]

B = [1, 8, 3, 6]

Output: Difference = |11 - 14| = 3 (or depending on the exact requested format, it could be Aws - Wael -3, or Wael - Aws 3).

Problem 2: Linked List Deletion (Multiple Choice)

Problem Description: You have written the following algorithm to delete a node from a singly linked list.

  • Step 1: Find the previous node of the node that is to be deleted.
  • Step 2: Change the next of the previous node.
  • Step 3: Free the memory of the node to be deleted.

Question: Which of the following are valid deductions that can be made about the given algorithm?

Answer Options:

  1. The algorithm is an iterative implementation
  2. The algorithm is a recursive implementation
  3. The algorithm cannot be further optimised
  4. None of the given options
ADD COMMENTlink 2 days ago admin 1.8k

Login before adding your answer.

Similar Posts
Loading Similar Posts