Skip to main content

TCS

TCS OA-9 2024

Problem Description

Given an integer n (the size of the array) and a list of n array elements, modify the array as follows:

  • If an element is divisible by 3, replace it with "Three".
  • If an element is divisible by 5, replace it with "Five".
  • If an element is divisible by both 3 and 5, replace it with "ThreeFive".
  • If none of the above conditions are met, keep the element as it is.

Finally, print the modified array.

Input Format

  • The first line contains an integer N, representing the array's length.
  • The second line contains N space-separated integers.

Output Format

Print the modified array according to the problem statement.

Constraints

  • 1 ≤ N ≤ 10⁵
  • 1 ≤ nums[i] ≤ 10⁵

Example

Sample Input:

4
[1 3 4 15]

Sample Output:

1 Three 4 ThreeFive

Explanation:

As 1 is neither divisible by 3 nor 5, so print 1 as it is.
3 is divisible by 3, so print "Three".
As 4 is neither divisible by 3 nor 5, so print 4 as it is.
15 is divisible by 3 and 5, so print "ThreeFive".