Find an Entry of Pascal’s Triangle
Updated
Problem statement
Return the entry at zero-based row and column in Pascal’s triangle. Row 0 is [1]. Every later row begins and ends with 1, and each interior entry is the sum of the two entries immediately above it.
For this exercise, column 0 is the leftmost entry and row r has r+1 entries. Inputs always satisfy 0<=column<=row. Return the exact integer value, without a modulus.
Function
pascalEntry(row: int, column: int) → intExamples
Example 1
row = 5column = 2return = 10Zero-based row 5 is [1,5,10,10,5,1]. Its column 2 entry is 10.
Example 2
row = 0column = 0return = 1The triangle’s top row is row 0, [1], whose only entry at column 0 is 1.
Constraints
- For this exercise, assume 0 <= row <= 30.
- For this exercise, assume 0 <= column <= 30.
- column is less than or equal to row.
More Morgan Stanley Online Assessment questions
- Three-Resource 0/1 KnapsackOA · Seen Sep 2026
- Maximum Concurrent ProcessesOA · ONSITE INTERVIEW · Seen Sep 2026
- Maximum Total of Nonadjacent RatingsOA · Seen Jul 2026
- Count Shipment SchedulesOA · Seen Apr 2026
- Delete and EarnOA · Seen Apr 2026
- Interleave Array HalvesOA · Seen Apr 2026
- Get Patch SequenceOA · Seen Feb 2025
- String Subsequences 🐳OA · Seen Mar 2024
- Binary Tree Level OrderOA · Seen Feb 2024
- Merge IntervalsOA · Seen Feb 2024
Similar questions at other companies
- Enough Muffins for the LineSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Count Numbers with Digit SumCisco · OACisco interview questions
- Climb Stairs with One or Two StepsIntuit · OAIntuit interview questions
- Count Lucky TicketsThe D.E. Shaw Group · OAThe D.E. Shaw Group interview questions
- Maximum Signal Walk in a Server TreeTower Research Capital · OA
- Maximum Score with Prime JumpsMicrosoft · OAMicrosoft interview questions
- Jump Game with Prime-3 StepsUber · OAUber interview questions
- Profitable Currency Exchange CycleOptiver · OAOptiver interview questions
- Count Valid A-B-C Sequences Under a Modulo-Four RuleInfosys · OAInfosys interview questions
- Unique Paths Through a GridPeopleStrong · OAPeopleStrong interview questions
Interview reports that mention this question
Morgan Stanley interview experiences
- Morgan Stanley Apprenticeship and Tech Interviews: 6 Experiences
- Morgan Stanley Intern Oldest Loops: 5 Experiences (Part 5 of 5)
- Morgan Stanley Intern OOP Loops: 5 Experiences (Part 4 of 5)
- Morgan Stanley Intern Earlier Loops: 5 Experiences (Part 3 of 5)
- Morgan Stanley Intern Tech Rounds: 5 Experiences (Part 2 of 5)