Input: aabbccdde → Output: abcde
If you would like to see like dynamic programming or matrix conversions. Share public link
Solution in Java:
return 0;
Identifying if a number's digits meet specific mathematical criteria. 3. Advanced (Digital/Prime Profile)
int index = 0; for (int i = k; i < n; i++) ans[i] = nums[index++];
Advanced test cases tracking memory bounds preferred sorting mechanisms and operations executed in-place rather than utilizing redundant arrays. Tcs Coding Questions 2021
approaches for smaller test cases, Digital questions require optimized solutions ( ) to pass strict time-out constraints.
#include #include #include using namespace std; int maxProductSubarray(vector & nums) if (nums.empty()) return 0; int max_so_far = nums[0]; int min_so_far = nums[0]; int result = max_so_far; for (size_size_t i = 1; i < nums.size(); i++) int curr = nums[i]; if (curr < 0) swap(max_so_far, min_so_far); max_so_far = max(curr, max_so_far * curr); min_so_far = min(curr, min_so_far * curr); result = max(max_so_far, result); return result; int main() vector nums = 2, 3, -2, 4; cout << "Max Product: " << maxProductSubarray(nums) << endl; return 0; Use code with caution. Question 5: Star and Hash Balance Checker Easy (TCS Ninja)
TCS 2021 coding questions were mostly implementation-based rather than algorithmic. Focus was on logic, edge cases, and clean code. Input: aabbccdde → Output: abcde If you would
vector<int> rotate(int nums[], int n, int k) if (k > n) k = k % n; vector<int> ans(n); for (int i = 0; i < k; i++) ans[i] = nums[n - k + i];
: Input oxygen levels for 3 trainees over 3 rounds. Calculate their average and identify the trainee with the highest average, provided it's above a minimum threshold. Preparation Resources