FastPrepCentered Star Pyramid
Problems/Centered Star Pyramid

Centered Star Pyramid

Bank of America logoBank of America● EasyNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Bank of America software engineering apprentice interview, in the first live technical round. The task was to print a pyramid made of stars.

The report does not give the exact shape. Here, each row is centered: row i has n - i spaces and then 2i - 1 stars, with nothing after the last star. You return the rows as a list of strings instead of printing them, and n is at most 100.

Our version is about 75% the same as the reported question.

Given an integer n, return the rows of a centered star pyramid with n rows, from top to bottom.

Rows are numbered from 1. Row i has n - i spaces followed by 2 * i - 1 stars (*). No row has spaces after its last star.

Function

buildPyramid(n: int) → String[]

Examples

Example 1

n = 3return = ["  *", " ***", "*****"]

Row 1 has 2 spaces and 1 star, row 2 has 1 space and 3 stars, and row 3 has no spaces and 5 stars.

Example 2

n = 1return = ["*"]

There is one row with one star and no spaces.

Example 3

n = 4return = ["   *", "  ***", " *****", "*******"]

Each row has one fewer space and two more stars than the row above it. Row 4 has no spaces and 7 stars.

Constraints

  • 1 <= n <= 100

More Bank of America Onsite Interview questions

  • Employees Without a ManagerONSITE INTERVIEW · Seen Nov 2025
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2025
  • N-th Fibonacci NumberONSITE INTERVIEW · Seen Nov 2025
  • Reverse Each Word in a SentenceONSITE INTERVIEW · Seen Nov 2025
  • Second Highest SalaryONSITE INTERVIEW · Seen Nov 2025
  • Three Numbers That Add Up to a TargetONSITE INTERVIEW · Seen Apr 2025
  • Duplicate RowsONSITE INTERVIEW · Seen Oct 2023
  • Factorial of a NumberONSITE INTERVIEW · Seen Oct 2023
  • Palindrome String CheckONSITE INTERVIEW · Seen Sep 2023
  • Second Largest Element in an ArrayONSITE INTERVIEW · Seen Jun 2023

Similar questions at other companies

  • Christmas Tree with N TiersVerily · ONSITE INTERVIEW
  • Bounded Word Guess SolverAtlassian · ONSITE INTERVIEWAtlassian interview questions
  • Document Edit EventsClickUp · ONSITE INTERVIEW
  • Predict Runtime Method DispatchAMD · ONSITE INTERVIEWAMD interview questions
  • Basic String Compression with Length GuardNew Relic · PHONE SCREEN · ONSITE INTERVIEW
  • Print Sentences as TableAirbnb · PHONE SCREEN · ONSITE INTERVIEWAirbnb interview questions
  • Retry with an Attempt LimitOracle · ONSITE INTERVIEWOracle interview questions
  • Extract Error Log ContextFlexTrade · ONSITE INTERVIEWFlexTrade interview questions
  • Run-Length Encode Consecutive Letter RunsMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions
  • String Pattern ReplacementGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions

Bank of America interview experiences

  • Bank of America interviews · December 2025
  • Bank of America OA · December 2025
  • Bank of America interviews · September 2026
  • Bank of America OA · September 2026
All Bank of America interview questionsSee Bank of America hiring insights
Saved
class Solution {
    public String[] buildPyramid(int n) {
        // write your code here
    }
}
Checking account…