Coding Questions 2021 Work - Tcs

public class Main public static boolean validPalindrome(String s) int left = 0, right = s.length() - 1; while (left < right) if (s.charAt(left) != s.charAt(right)) left++; right--; return true; private static boolean isPalindrome(String s, int left, int right) while (left < right) if (s.charAt(left) != s.charAt(right)) return false; left++; right--; return true;

Problem Statement: A scientist has discovered a new number system where the base is 2. Write a program to convert a given decimal number (N) into its binary equivalent. However, you cannot use the bin() function or inbuilt conversion libraries. Additionally, find the number of '1's in the binary representation (Hamming Weight). Tcs Coding Questions 2021

You are given an array of heights of students. Find the minimum number of jumps required to reach the end of the array, where you can jump from index i to i+1, i+2, or i+3 , but you cannot land on an index where the height is greater than the current height. This was the "killer" problem in TCS Digital December 2021. Conclusion The TCS coding questions from 2021 represent a sweet spot in the company’s hiring history—modern enough to test logic, yet classic enough to be predictable. By focusing on array manipulation, two-pointer techniques, recursion, and edge-case handling, you can easily score 85%+ in the coding section. Additionally, find the number of '1's in the

#include <iostream> #include <climits> using namespace std; int main() int arr[] = 12, 35, 1, 10, 34, 1; int n = sizeof(arr)/sizeof(arr[0]); This was the "killer" problem in TCS Digital December 2021