FastPrepCluster Size on Disk
Problems/Cluster Size on Disk

Cluster Size on Disk

Upstart logoUpstart● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The original report names computeSizeOnDisk(clusterSize, fileSize) but leaves out the allocation rule and the rule for empty files. We use the usual cluster-rounding rule, described below. Our version is about 76% the same as the reported question.

A storage device allocates file space in fixed-size clusters. A non-empty file occupies the smallest whole number of clusters whose combined capacity is at least the file's logical size.

Given a positive clusterSize in bytes and a non-negative fileSize in bytes, return the number of bytes allocated on disk. A file of size 0 occupies 0 bytes.

Function

computeSizeOnDisk(clusterSize: long, fileSize: long) → long

Examples

Example 1

clusterSize = 4096fileSize = 1return = 4096

Even one byte requires one complete 4096-byte cluster.

Example 2

clusterSize = 4096fileSize = 8193return = 12288

Two clusters hold only 8192 bytes, so the file needs three clusters.

Constraints

  • 1 <= clusterSize <= 10^9.
  • 0 <= fileSize <= 10^18.
  • The allocated result fits in a signed 64-bit integer.

More Upstart Online Assessment questions

  • Buffet Day GainsOA · Seen Sep 2026
  • Case-Insensitive Anagram CheckOA · Seen Sep 2026
  • Filter Duplicates While Preserving OrderOA · Seen Sep 2026
  • Scale Ingredient QuantitiesOA · Seen Sep 2026
  • ABO Parent Genotype CombinationsOA · Seen Aug 2026
  • Chunked Byte Stream ChecksumsOA · Seen Aug 2026
  • Double Substitution DecryptionOA · Seen Aug 2026
  • Add Drama to Text GroupsOA · Seen Jul 2026
  • Lexicographic Word FrequenciesOA · Seen Jul 2026
  • Minimum Absolute Pair DifferenceOA · Seen Jul 2026

Similar questions at other companies

  • Summarize Taxi Drivers and RidesBoston Consulting Group · OABoston Consulting Group interview questions
  • Total Cost Against the Lowest Earlier PricePayPal · OAPayPal interview questions
  • Count Valid Square PairsAuxoAI · OA
  • Counting Cows by Their LegsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Server InvestmentRippling · OARippling interview questions
  • Basic Item DiscountsPalantir · OAPalantir interview questions
  • Identification Number Check DigitAbridge · OAAbridge interview questions
  • Count Substrings With Identical CharactersVirtu Financial · OAVirtu Financial interview questions
  • Next Pascal Row CoefficientIntuit · OAIntuit interview questions
  • Digit-Sum Sequence Join PointOpenAI · OAOpenAI interview questions
All Upstart interview questionsSee Upstart hiring insights
Saved
class Solution {
    public long computeSizeOnDisk(long clusterSize, long fileSize) {
        // Write your code here.
    }
}
Checking account…