Maximum Frog Separation with One Upward Jump (Practice Reconstruction)
Updated
Problem statement
A row of blocks has heights blocks[i]. For this exercise, assume two frogs begin together on one block of your choice.
Each frog may stay or make at most one jump. A jump moves to an adjacent block whose height is strictly greater than the starting block height. The frogs may occupy the same block.
For this exercise, measure their final distance as the absolute difference between their final block indices. Return the maximum possible distance after choosing the shared start and each frog's allowed move.
Function
solution(blocks: int[]) → intExamples
Example 1
blocks = [4,1,5]return = 2This example starts at index 1. The frogs jump to indices 0 and 2, whose distance is 2.
Example 2
blocks = [1,2,3,4]return = 1This example allows only one adjacent jump per frog. Choose any lower block, keep one frog there and move the other right by one.
Example 3
blocks = [5,5]return = 0This example has no strictly higher neighbour. Both frogs stay together, giving distance zero.
Constraints
- For this exercise, assume
1 <= blocks.length <= 100000. - For this exercise, assume
0 <= blocks[i] <= 10^9.
More Marshall Wace interview questions
- Maximum Sum with at Most Three Two-Element TilesPHONE SCREEN · Seen Sep 2025
- Minimum Full Glasses for an Exact Water VolumePHONE SCREEN · Seen Sep 2025
- Smallest Absolute Difference Between Two Array ElementsPHONE SCREEN · Seen Sep 2025
- Minimum Deletions Before Rearranging into a PalindromePHONE SCREEN · Seen Jul 2023
- Smallest Larger Integer with Twice the Digit SumPHONE SCREEN · Seen Jul 2023
- Count Squares of Any OrientationPHONE SCREEN · Seen Oct 2019
- Count Letters with Ordered Lowercase and Uppercase OccurrencesOA · Seen Oct 2025
- Maximum Trailing Zeros on a Path with at Most One TurnOA · Seen Oct 2025
- Shortest Subarray Covering an Integer RangeOA · Seen Oct 2025
- Maximum Events in a 60-Second WindowOA · Seen Aug 2025
Similar questions at other companies
- Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
- Search and Format ContactsAdyen · PHONE SCREENAdyen interview questions
- Array-Backed Set Without Library CollectionsOde with Anthropic · PHONE SCREEN
- Paginate Retained Conversation HistorySierra · PHONE SCREENSierra interview questions
- Validate a Chess Bishop, Rook, or Queen MoveGlean · PHONE SCREENGlean interview questions
- Count Distinct Underwriting PII ValuesAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
- Apply Affine Array TransformationsByteDance · PHONE SCREENByteDance interview questions
- Match a Variadic Function SignatureConfluent · PHONE SCREENConfluent interview questions
- Bounded IPv4 FilterAmazon · PHONE SCREEN
- Partition and Group Values by ParityEPAM · PHONE SCREENEPAM interview questions