Flipkart GRID 8.0 OA questions Shift 11 am 18th July
Anonymous User
274

Formatted with GPT.
Total 4 questions, 2 dsa + 1 sql + 1 data frame coding(only py allowed)

You are given N cookies, each having a specific weight. The cookies must be packed into a nested box structure following a specific rule.

Packing Rules

  • Each box consists of three portions:

    • Left: contains one cookie
    • Center: contains another box (recursive structure)
    • Right: contains one cookie
  • The cookies must be arranged such that:

    • The center box contains the smallest weights
    • The left portion contains medium weights
    • The right portion contains the largest weights

This effectively forms a recursive nested structure similar to a tree.

Tasks

  1. Construct the packing structure.

  2. Represent the structure using bracket notation:

    • Format: [left [center] right]
  3. Given a target cookie weight, determine the box level (depth) at which it is placed:

    • The outermost box is at level 1.

Input

  • Integer N
  • Array of N integers representing weights
  • Integer target (weight to search)

Output

  • String representing the packing structure
  • Integer representing the box level of the target cookie

Example

Input

N = 5
weights = [76, 62, 99, 21, 39]
target = 99

Output

Structure: [76[62[21]39]99]
Box level of 99: 3

Problem 2: Custom Power Function

You are given a list of integers. Each integer represents a number encoded in a special format.

Definition of f(x)

For a number x:

  • The last digit of x represents k, the number of digits to be used as the exponent.
  • The remaining leading digits form the base.

Let:

  • base = first (len(x) - k digits)
  • exponent = last k digits

Then:

f(x) = base ^ exponent

Task

Compute the sum of f(x) for all numbers in the list.

Input

  • List of integers

Output

  • Integer representing the sum

Example

Input

[4122, 2021]

Explanation

  • 4122 → last digit = 2 → exponent = 12, base = 4 → 4^12
  • 2021 → last digit = 1 → exponent = 2, base = 20 → 20^2

Output

4^12 + 20^2 = 16777216 + 400 = 16777616

Comments (3)