← All problemsSign in

Perm Issue

Alice and Bob are playing a game of Arrays where Alice gives Bob 2 arrays **A** and **B** of size **N** and **M**, and asks Bob to find the *number of permutations* of array A which are *lexicographically smaller* than B. An array P is lexicographically smaller than array Q, if there exists an index i such that for every index j < i, P[j] = Q[j] and P[i] < Q[i] or array P is prefix of array Q and

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start