OA. free
Free
Phone Pe Data Structures & Algorithms Data Structures & Algorithms Medium

Problem 1: Node Importance Sum Given an array representing the importance value of nodes,...

Phone Pe technical mcq question, verified with a worked answer. Free to practise - no sign-up.

Problem 1: Node Importance Sum

Given an array representing the importance value of nodes, return the total importance value of a node and its child nodes.


Problem 2: Sweet Sweetness Calculation

A vector contains values representing the sweetness of sweets, where sweet[i] is the sweetness of the i-th sweet. The total sweetness is calculated as:

total_sweetness = Σ (m * sweet[m] * (1 - base_index))

There are three supported operations:

Choose one option.
Show answer & explanation
Answer: C. Add a new sweet with sweetness k.

The question asks to identify the supported operations for the 'sweetness' problem described in point 2. The problem explicitly lists three operations: reversing the array, circular right shift, and adding a new sweet with sweetness k.

Step-by-step Derivation:
Step 1: Analyze the problem statement provided in section 2 of the prompt.
Step 2: Identify the listed operations under the 'sweetness' scenario. The text explicitly states: 'There are three supported operations: A. Reverse the entire array. B. Perform a circular right shift. C. Add a new sweet with sweetness k.'
Step 3: Compare these listed operations with the provided multiple-choice options (Option A, Option B, Option C).
Step 4: Since the question asks for the operations associated with the sweetness problem, and Option C ('Add a new sweet with sweetness k') is explicitly listed as one of the three supported operations in the problem description, it is a correct identification of a supported operation.