Answer: SCHLUMBERGER (SLB) Hiring | Off-Campus OA (2024) | Arrays
Answer · Posted Jun 2026
Approach Every single element forms a descent period. Maintain the current length of the descending sequence. If the current price is exactly one less than the previous price, extend the sequence. Otherwise, start a new sequence. Add the current sequence length to the answer. Strategy Initialize result and consecutive length as 1. Traverse the array. Extend the descent sequence if possible. Otherwise reset the sequence length. Add the current sequence length to the answer. Return the result. Java Code class ...
The full answer & interview discussion are available to premium members.
Log in Create a free account