FastPrepOrdered Book Displays with a Featured Book
Problems/Ordered Book Displays with a Featured Book

Ordered Book Displays with a Featured Book

IMC Trading logoIMC Trading● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an IMC Trading new grad online assessment. The reported question orders four different books out of thirty, then highlights one of the books on display. Our counting task is about 95% the same. This version works for any counts, and says what to do with an empty display or a display that is too big.

A library owns n distinct books. Create a display by choosing k different books and arranging them in a specific order.

After arranging the display, choose exactly one of its books as the featured Book of the Month. Two results differ if their ordered display differs or their featured book differs.

Return the number of possible display-and-feature choices. A book cannot appear twice in a display, and the featured book must belong to the display.

For this exercise, assume n and k generalize the thirty-book, four-position case in the first example. If k = 0 or k > n, return 0: no featured displayed book can be selected.

Complete countBookDisplays(n, k) and return the exact count as a signed 64-bit integer.

Function

countBookDisplays(n: int, k: int) → long

Examples

Example 1

n = 30k = 4return = 2630880

The four ordered positions have 30 * 29 * 28 * 27 = 657720 possible assignments. Each has four possible featured books, so the count is 657720 * 4 = 2630880.

Example 2

n = 3k = 2return = 12

The ordered pairs are [A,B], [A,C], [B,A], [B,C], [C,A], and [C,B]. Each pair has two featured choices, giving 12.

Example 3

n = 4k = 0return = 0

An empty display contains no book to feature.

Example 4

n = 2k = 3return = 0

Three distinct displayed books cannot be selected from only two books.

Constraints

  • For this exercise, assume 0 <= n <= 50 and 0 <= k <= 10.
  • Books are distinct and may be selected only once.
  • The exact answer and the intermediates in the presented solutions fit in signed 64-bit arithmetic.

More IMC Trading Online Assessment questions

  • Earliest Meeting Start on a 24-Hour ClockOA · Seen Nov 2026
  • Grid Paths with Override PassesOA · Seen Oct 2026
  • Weighted LFU CacheOA · Seen Sep 2026
  • Rock JumpingOA · Seen Aug 2026
  • Stack Batch RemovalOA · Seen Aug 2026
  • Chain of CommandOA · Seen Aug 2026
  • Choose ContainersOA · Seen Aug 2026
  • Sub-matrix SumsOA · Seen Jul 2026
  • Sub-matrix SumsOA · Seen Jul 2026
  • Can Every Package Fit in a BoxOA · Seen Jul 2026

Similar questions at other companies

  • Enough Muffins for the LineSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Next Pascal Row CoefficientIntuit · OAIntuit interview questions
  • Subarray SumVisa · OAVisa interview questions
  • Drawing EdgeWeRide · OAWeRide interview questions
  • Drawing EdgeIBM · OAIBM interview questions
  • Drawing EdgeSnowflake · OASnowflake interview questions
  • Process SchedulingCitadel · OACitadel interview questions
  • Unique Digits in RangeAgoda · OAAgoda interview questions
  • Find Max Number of PairsRoblox · OARoblox interview questions
  • Count Distinct Arrays After Decrement OperationsBloomberg LP · OABloomberg LP interview questions

Interview reports that mention this question

  • IMC Trading OA: What It Tests (2026)

IMC Trading interview experiences

  • IMC Trading SWE OA and Video: 18 Experiences (Part 3 of 3)
  • IMC Trading SWE OA Questions: 22 Experiences (Part 2 of 3)
  • IMC SWE New Grad OA and Interviews: 58 Experiences (Part 1 of 3)
All IMC Trading interview questionsSee IMC Trading hiring insights
Saved
class Solution {
    public long countBookDisplays(int n, int k) {
        // Write your solution here.
    }
}
Checking account…