FastPrepComplete Rows of a Coin Staircase
Problems/Complete Rows of a Coin Staircase

Complete Rows of a Coin Staircase

Expedia logoExpedia● EasyINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two posts published on September 8, 2018, each by a student at a college visited by Expedia for intern hiring, name this task among the questions of the first online round.

Neither post gives limits or examples, and one speaks of a maximum height rather than a number of coins. The first post also remarks on running time. We do not model that remark. The tests check answers only, and any correct method is accepted. Here, the input is a coin count between 1 and 2^31 - 1, and the answer is the number of rows that are completely filled.

Our version is about 85% the same as the reported questions.

You have n coins and want to lay them out as a staircase. Row 1 needs 1 coin, row 2 needs 2 coins, row 3 needs 3 coins, and in general row k needs exactly k coins.

Fill the rows in order, starting with row 1. A row counts only when it gets all of its coins, so a last row that is only partly filled does not count.

Return the number of complete rows.

Function

arrangeCoins(n: int) → int

Examples

Example 1

n = 38return = 8

The first 8 rows use 1 + 2 + ... + 8 = 36 coins. Row 9 would need 9 more, but only 38 - 36 = 2 coins are left, so that row stays incomplete. The answer is 8.

Example 2

n = 78return = 12

The first 12 rows use 1 + 2 + ... + 12 = 78 coins, exactly all of them, so there are 12 complete rows and nothing is left over.

Example 3

n = 2024return = 63

63 rows use 63 * 64 / 2 = 2016 coins. Row 64 would need 64 more, but only 2024 - 2016 = 8 coins are left. The answer is 63.

Constraints

  • 1 <= n <= 2^31 - 1

More Expedia Online Assessment questions

  • Balanced NumbersOA · Seen Aug 2026
  • REST API: Discounted PriceOA · Seen Aug 2026
  • Maximum Team SizeOA · Seen Mar 2026
  • Per-Domain Request LimiterOA · Seen Oct 2025
  • Count Equal-Frequency SubsequencesOA · Seen Mar 2025
  • Count Increasing Stock PeriodsOA · Seen Mar 2025
  • Get Minimum StepsOA · Seen Oct 2024
  • Rank Songs by PopularityOA · Seen Oct 2024
  • Calculate the SumOA · Seen Oct 2024
  • Get Maximum EfficiencyOA · Seen Oct 2024

Similar questions at other companies

  • Floor Square Roots for an ArrayWells Fargo · OAWells Fargo interview questions
  • Days to Overtake Another CoderJP Morgan Chase · OAJP Morgan Chase interview questions
  • Arrange CoinsAlarm.com · OA
  • Perfect Squares Matching a PatternNielsen · OA
  • Maximum Alloy Production Within BudgetMicrosoft · OAMicrosoft interview questions
  • Linear InterpolatorTwo Sigma · OATwo Sigma interview questions
  • Rock JumpingIMC Trading · OAIMC Trading interview questions
  • Count Lucky Numbers in a RangeTarget · OA
  • Cyber Beacon DetectionRippling · OARippling interview questions
  • Souvenir Shop PurchasesAmazon · OA

Expedia interview experiences

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
  • Expedia SWE Intern Final Round: 126 Experiences (Part 1 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public int arrangeCoins(int n) {
        // Write your code here.
    }
}
Checking account…