FastPrepPaint the Ceiling
Problems/Paint the Ceiling

Paint the Ceiling

Roblox logoRoblox● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The candidate calls the task Painting the Cell and links Paint the Ceiling. A separate reference image gives the recurrence and an example with ordered pairs of sides. We added the interface and the number limits. Our version is about 95% the same as the reported question.

Generate n allowed side lengths. Set s[0] = s0 and, for i > 0, set s[i] = s[i-1] + 1 + ((k * s[i-1] + b) mod m).

Count ordered pairs of indices (i,j) whose rectangle area s[i] * s[j] is at most area. Both orientations count separately when the indices differ, and using the same side twice is allowed. For example, sides [2,4,6] with area limit 15 allow (2,2), (2,4), (2,6), (4,2), (6,2), giving 5.

For this exercise, assume the bounds below and return a signed 64-bit count. Intermediate area products can exceed 64-bit range; compare them without overflow.

Function

paintTheCeiling(s0: int, n: int, k: int, b: int, m: int, area: long) → long

Examples

Example 1

s0 = 2n = 3k = 3b = 3m = 2area = 15return = 5

The recurrence gives 2, 4, 6; the five ordered pairs are listed in the statement.

Example 2

s0 = 3n = 1k = 0b = 0m = 1area = 9return = 1

The only available side is 3; its square has area 9.

Example 3

s0 = 4n = 2k = 0b = 0m = 1area = 15return = 0

The sides are 4 and 5, and even the smallest square has area 16.

Constraints

  • 1 <= n <= 100000.
  • 1 <= s0, m <= 1000000.
  • 0 <= k, b <= 1000000.
  • 1 <= area <= 1000000000000000000.
  • The recurrence’s multiplication fits signed 64-bit under these limits, while side-area products need not.

More Roblox Online Assessment questions

  • Centered Block Placement QueriesOA · Seen Oct 2026
  • Robot Navigation Around LasersOA · Seen Oct 2026
  • Factory Batch Profit (Game Adaptation)OA · Seen Sep 2026
  • Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
  • Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
  • Track Received Byte RangesOA · Seen Sep 2026
  • Break a PalindromeOA · Seen Jun 2026
  • Count Pairs Differing in One DigitOA · Seen Oct 2025
  • Find Zero Cells in a 2×2 GridOA · Seen Oct 2025
  • Cat Route Budget Planning (Game Adaptation)OA · Seen Aug 2025

Similar questions at other companies

  • Paint the CeilingWeRide · OAWeRide interview questions
  • Fastest Average Speed over a Rolling KilometerOptiver · OAOptiver interview questions
  • Find All Pythagorean TripletsDell Technologies · PHONE SCREENDell Technologies interview questions
  • Sort a Quadratic-Transformed ArrayLinkedIn · PHONE SCREENLinkedIn interview questions
  • Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
  • Fill Missing Points on Line SegmentsDatadog · PHONE SCREENDatadog interview questions
  • Count Centaur Friend RequestsMeta · PHONE SCREENMeta interview questions
  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Count Subarrays With Product Equal to KSalesforce · OASalesforce interview questions

Interview reports that mention this question

  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)

Roblox interview experiences

  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
  • Roblox New Grad Coding Rounds: 23 Experiences (Part 2 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public long paintTheCeiling(int s0, int n, int k, int b, int m, long area) {
        // write your code here
    }

}
Checking account…