Tcs Coding Questions 2021 -

Input: "1100111001" Output: 3 (groups: "11", "111", "1")

This was a "modified greedy" problem that required recursion or DP. Question 5: "Binary String Operations" (Grouping Ones) Problem Statement: Given a binary string (e.g., "1001101"), you can perform operations: choose any contiguous substring containing exactly two '1's and flip all bits (0→1, 1→0). Find the minimum number of operations to make all bits '0'. Tcs Coding Questions 2021

TCS loved problems that mix string indexing and array frequency. Question 4: "Minimum Coins" (Greedy Algorithm – Modified) Problem Statement: In a foreign country, the currency denominations are [1, 3, 5, 10, 25, 50] . Given an amount M (≤ 1000), find the minimum number of coins needed. But with a twist: You cannot use the 10-rupee coin if the remaining amount after using other coins is divisible by 3. Input: "1100111001" Output: 3 (groups: "11", "111", "1")