TCS TCS OA-32 2024 Problem Description You are tasked with implementing solutions related to the Collatz sequence for a given positive integer n. The Collatz sequence for a number n is defined by the following rules: 1. If n is even, the next term is n/2. 2. If n is odd, the next
TCS TCS OA-31 2024 Problem Description You are given an array of integers, nums, and an integer k. Your task is to find and print all contiguous non-empty subarrays within nums whose sum equals k. Input Format * The first line contains an integer N, representing the array's length. * The second line contains
TCS TCS OA-30 2024 Problem Description Given an N x N matrix where 1 represents a cell that can be visited and 0 represents a blocked cell, find all possible paths from the top-left cell (0, 0) to the bottom-right cell (N-1, N-1). The rat can only move in four directions: up, down, left,
TCS TCS OA-29 2024 Problem Description You are given a string S consisting of the characters # and x. The length of the string is variable. Your task is to determine the minimum number of characters (# or x) required to make the string "valid." The string is considered valid if the number of
TCS TCS OA-28 2024 Problem Description A mall has a parking lot represented as a grid of R×C parking spaces, where R is the number of rows and C is the number of columns in the parking lot. Each parking space is either: * Empty (denoted by 0) * Occupied (denoted by 1) The parking
TCS TCS OA-27 2024 Problem Description You are given a robot positioned at the top-left corner of an m×n grid, represented by coordinates (0,0). The robot aims to reach the bottom-right corner of the grid, located at (m−1,n−1). The robot can only move in two directions at any given
TCS TCS OA-26 2024 Problem Description Given two integers n and m, find the sum of the cubes of all integers from n to m, inclusive. The function should handle cases where n is greater than m and treat n as the starting point and m as the ending point of the range. Input
TCS TCS OA-25 2024 Problem Description Given an integer n, you are required to calculate the sum of the first 10 values in the multiplication table of n. Specifically, you need to compute: n×1+n×2+⋯+n×10 Input Format The first line contains an integer n. Output Format An integer representing the
TCS TCS OA-24 2024 Problem Description You are given an array of integers, arr, and an integer k. Your task is to find the maximum element in each contiguous subarray of size k within arr. Input Format * The first line contains an integer N, representing the array's length. * The second line contains
TCS TCS OA-23 2024 Problem Description You are given a positive integer N. Your task is to calculate and return the sum of the first N terms in the Fibonacci series. The Fibonacci series is defined as: * F(0)=0 * F(1)=1 * F(n)=F(n−1)+F(n−2) for n≥2
TCS TCS OA-22 2024 Problem Description You are given an integer array arr. Your task is to find the number of distinct bitwise OR results from all possible non-empty subarrays of arr. A subarray is a contiguous, non-empty sequence of elements within an array. The bitwise OR of a subarray is obtained by performing
TCS TCS OA-21 2024 Problem Description In a database containing information about N students, each student record has the following fields: * Name: A string representing the student's name. * Age: An integer representing the student's age. * Grade: A string of length 1 representing the student's grade (e.g., '
TCS TCS OA-20 2024 Problem Description You are given an array of numbers, and your job is to find the majority element. The majority element is the one that shows up more than half the time in the array. Input Format * The first line contains an integer N, representing the array's length.
TCS TCS OA-19 2024 Problem Description In an organization’s data warehouse, each entry includes a three-digit number. You are tasked with determining if the given three-digit number is divisible by 9. Input Format * An integer num, which is a three-digit number. Output Format Print "Yes" if the number is divisible by
TCS TCS OA-18 2024 Problem Description We are given a list of numbers. We need to return the maximum difference between the smallest and largest number. Note: Smallest number should be before largest number. Input Format * The first line contains an integer N, representing the array's length. * The second line contains N
TCS TCS OA-17 2024 Problem Description A person owns a collection of shoes, where each shoe has both a size and a side (either left "L" or right "R"). Each shoe is represented in the form of a string, sizeSide, where size is an integer indicating the shoe size, and
TCS TCS OA-16 2024 Problem Description In a company, the efficiency of each employee is represented by an integer value in the array arr. The efficiencies can be positive, negative, or zero. Your task is to find the maximum possible efficiency that can be achieved by selecting any three employees. The efficiency of the
TCS TCS OA-15 2024 Problem Description Given an integer array of size n, find all elements that appear more than one-third of the time. 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 all elements that appear more
TCS TCS OA-14 2024 Problem Description You are given an array nums consisting of n objects that are colored red, white, or blue. The colors are represented by the following integers: * Red: 3 * White: 6 * Blue: 7 Your task is to sort the array in-place such that: 1. All objects of the same color
TCS OA-13 2024 Problem Description Given an array of size N containing integers in the range of[1, N+1], the task is to find the missing number from the first N integers. The array is guaranteed to contain distinct integers, and exactly one integer from the range is missing. Input Format * The
TCS TCS OA-12 2024 Problem Description Write a program that accepts two integers, n and m, and prints all prime numbers between n and m (inclusive) such that the sum of their digits is also a prime number. Input Format The first line contains two integers n and m. Output Format Print all prime
TCS TCS OA-11 2024 Problem Description Write a program that takes two integers, X and Y, as inputs. The program should find and print the number that is closest to X and is divisible by Y. Input Format * The first line contains two integers X and Y. Output Format Print the number which is
TCS TCS OA-10 2024 Problem Description Write a program that generates a modified password based on an initial password and an increment value, following these requirements: 1. The initial password must be at least 8 characters long. 2. It must contain at least: * One integer, * One special character from the set {'#', '
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
TCS TCS OA-8 2024 Problem Description Given an integer n, return true if it is an Armstrong number; otherwise, return false. An Armstrong number is a number that equals the sum of its own digits, each raised to the power of the number of digits. Input Format The first line contains an integer N.