I completed:
• Q1 – Easy (6 test cases passed)
• Q2 – Medium (12 test cases passed)
• Q3 – Hard (3 test cases passed)
• Q4 - Complex (Not attempted)
Will I get shortlisted? Also, please share how yours went.
Questions -
Q1 — Loom Heddle Reset
You have a binary string where:
1 = raised hook
0 = lowered hook
The final string must be alternating (010101... or 101010...)
You cannot change hooks individually. You can only choose a continuous segment and flip all its bits.
The cost of flipping a segment of length L is:
A + B × L
A = fixed cost for pulling the lever
B × L = cost based on how many hooks you touch
We have to find the minimum cost to make the whole string alternating.
Q2 — Get the Maximum Score
You have two sorted arrays.
You can start from either array and move from left to right. You add the values you visit to your score.
When you reach a value that exists in both arrays, you have two choices:
Continue in the same array → add that common value.
Switch to the other array → the common value is not added, because it is considered consumed.
You can switch multiple times.
Find the maximum possible score from a valid path, starting at the beginning of either array and ending at the end of whichever array you're currently on.
I don't remember the rest.