Question: Flipkart OA Coding Round | Path Concatenation & Carrot Collection Logic | Recent Online Assessment 2025 | Binary Tree Sum & Matrix Optimization | Latest Flipkart Placement Questions
0
Entering edit mode

Question 1: Path Concatenation Sum in a Binary Tree

Problem Statement:

Consider a binary tree with N nodes (1 Root and N-1 descendants). Each node, X is related to the Root by some relations such as L, R, LL, LR... and so on, where X is left (L) to Root or left-left (LL) or right-left (RL) to Root and so on.

Perform the following operations to find the value of Sum.

  1. If the given tree has M leaf nodes, there will be M minimum paths from root to M leaf nodes. Each path, Path_i, is the path from root to i^{th} leaf node, where 1 <= i <= M. Find all such paths.
  2. Concatenate all node values along the Path_i to form an integer P_i, where 1 <= i <=M.
  3. Calculate Sum, where Sum = P_1 + P_2 +....... + P_M.

Write a program to print Sum.

Constraints:

  • Node values are always greater than or equal to 0.

Question 2: Maximum Carrots in a Matrix (Rabbit's Journey)

Problem Statement:

A field, represented as cells of an M * N matrix, is given. There are some carrots in every cell, and a rabbit is trying to cross the field while eating the carrots available on the way. He starts from the top-left cell and moves right or down in each step, and finally reaches the bottom-right cell.

Write a program to find the maximum number of carrots the rabbit can eat during the trip from the top-left cell to the bottom-right cell.

Note: The Rabbit always moves either to downfield or right field, and always consumes all the carrots available in the cells on its path.

Input Format:

  • The first line of input contains two integers M and N separated by a single white space, where M and N represent the size of the field.
  • Next M lines have N integers, separated by a single white space, which represents the number of carrots in each cell.
ADD COMMENTlink 23 hours ago admin 1.8k

Login before adding your answer.

Similar Posts
Loading Similar Posts