Maximum Student-Teacher Distance
Updated
Problem statement
Students occupy positions 0 through n - 1. For every position, return the maximum absolute distance to any teacher in teacherPositions.
Function
maximumTeacherDistances(n: int, teacherPositions: int[]) → int[]Examples
Example 1
n = 5teacherPositions = [3,0,1,4]return = [4,3,2,3,4]Only the leftmost and rightmost teacher can maximize a student's absolute distance.
Example 2
n = 1teacherPositions = [0]return = [0]Only the leftmost and rightmost teacher can maximize a student's absolute distance.
Example 3
n = 5teacherPositions = [2]return = [2,1,0,1,2]Only the leftmost and rightmost teacher can maximize a student's absolute distance.
Constraints
1 <= n <= 200000.1 <= teacherPositions.length <= n.0 <= teacherPositions[i] < n.
Source note: Author-written prompt excerpt retained for source fidelity.
More Chubb Online Assessment questions
- Count Pairs with K Divisible Values in the IntervalOA · Seen Oct 2026
- Index of the Maximum After Left RotationsOA · Seen Oct 2026
- Maximize Revenue from Decreasing InventoryOA · Seen Oct 2026
- Minimize the Maximum Array ElementOA · Seen Oct 2026
- Minimum Distinct Prefix CostOA · Seen Oct 2026
- Flat JSON Value DifferencesOA · Seen Sep 2026
- Minimum Cost to Reach a Target WeightOA · Seen Sep 2026
- Minimum Last-Element RelocationsOA · Seen Sep 2026
- Most Visited Sprint MarkerOA · Seen Sep 2026
- How Many Sentences?OA · Seen Sep 2026
Similar questions at other companies
- Total Cost Against the Lowest Earlier PricePayPal · OAPayPal interview questions
- Count Valid Square PairsAuxoAI · OA
- Picked Player Who LostSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Server InvestmentRippling · OARippling interview questions
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Next Pascal Row CoefficientIntuit · OAIntuit interview questions
- Unique Integers That Sum to ZeroNVIDIA · OANVIDIA interview questions
- Count Multiples of Three with Two SevensHudson River Trading · OAHudson River Trading interview questions
- Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
- Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions