TATA CONSULTANCY SERVICES (TCS DIGITAL) | Off Campus OA (2024) |Sort the People

TCS · Question · Posted Jun 2026

Problem Statement You are given two arrays: names[] where names[i] represents the name of the i-th person. heights[] where heights[i] represents the height of the i-th person. The height of each person is unique. Your task is to sort the people in descending order of their heights and return the corresponding names in that order. Example 1 Input names = ["Mary","John","Emma"] heights = [180,165,170] Output ["Mary","Emma","John"] Explanation Height mapping: Mary -> 180 John -> 165 Emma -> 170 Sorting by ...

The full answer & interview discussion are available to premium members.

Log in Create a free account