TCS Previous Coding Questions

TCS Previous Coding Questions Banner
Problem - Vehicles and Wheels

An automobile company manufactures both a two wheeler (TW) and a four wheeler (FW). A company manager wants to make the production of both types of vehicle according to the given data below:

  • 1st data, Total number of vehicle (two-wheeler + four-wheeler) = v
  • 2nd data, Total number of wheels = W
Problem - Find Count of Elements Greater Than All Prior Elements

Given an integer array Arr of size N, find the count of elements whose value is greater than all of its prior elements. (Note: The 1st element is always counted.)

Example: Arr[] = {7, 4, 8, 2, 9}Output: 3
Problem - Find the Row with Maximum Parking Spaces Full

A parking lot in a mall has R x C number of parking spaces. Each parking space will either be empty (0) or full (1). The task is to find the index of the row (R) in the parking lot that has the most parking spaces full (1).

Problem - Maximum Guests on a Cruise

A party has been organised on a cruise for a limited time (T). The number of guests entering (E[i]) and leaving (L[i]) the party at every hour is represented as elements of the array. The task is to find the maximum number of guests present on the cruise at any given instance within T hours.

Problem - Toggle All Bits from MSB

A positive integer has been given as an input. Convert the decimal value to its binary representation. Toggle all bits of it after the most significant bit including the most significant bit. Print the positive integer value after toggling all bits.

Note:
  • If the input is non-positive or invalid, the program should print INVALID INPUT.
  • All bits from the Most Significant Bit (MSB) down to the Least Significant Bit (LSB) are inverted (0 becomes 1, and 1 becomes 0).
Example: Input: 10 (Binary: 1010) → Toggle from MSB: 0101Output: 5

Total Pageviews