Lexicographic Rank with Repeated Letters: Count Prefix Blocks
Find the rank of LEVEL using smaller prefix blocks. Update repeated-letter counts, avoid duplicate choices and add one for a one-based rank.

| Topic | Exam Prep |
|---|---|
| Focus | Mathematics |
| Read time | 5 min |
| Words | 939 |
| Published | 25 Nov 2026 |
| Best for | Parents & students |
The rank of a word is one more than the number of arrangements that come before it. With repeated letters, the main difficulty is not the final addition. It is counting each earlier prefix block once while updating the letters still available.
This guide uses alphabetical order and all distinct arrangements of the supplied letters, whether or not they form dictionary words. Rank starts at 1. If a question supplies a different letter order or starts counting at zero, follow that convention instead.
If factorial notation or repeated-object counts need revision, use our Class 11 permutations and combinations practice first. The task here is different: locating one specified word within the ordered arrangements.
Count earlier prefixes, not entire lists
Imagine a sorted list of arrangements. All arrangements beginning with E occur before all arrangements beginning with L. Within a shared first letter, compare the second letter, then the third, until the first difference.
To rank a target, count blocks whose first difference makes them smaller. Once a prefix is already smaller, every valid completion belongs in that block. You do not need to compare its later letters with the target.
At each position, try every distinct available letter smaller than the target letter. Temporarily remove that candidate. If n letters remain with repeated counts a, b and so on, that candidate's block contains n!/(a!b!...) arrangements.
Restore the candidate after counting its block. When all smaller candidates at this position are finished, remove the actual target letter and move right. The denominator changes because the remaining multiplicities change.
Worked example: the rank of LEVEL
The letters are E, E, L, L and V, with E before L before V. We will keep the prefix equal to LEVEL until we deliberately choose a smaller letter. Every number below is an independently calculated exercise value.
- First position, target L: E is the only smaller available letter. After placing E, the remaining letters are E, L, L, V. They make 4!/2! = 12 completions. Count 12 earlier arrangements, then consume the actual L.
- Second position, target E: the available letters are E, E, L, V. None is smaller than E, so add zero. Consume E. The fixed prefix is now LE.
- Third position, target V: the remaining letters are E, L, V. Choosing E leaves L and V, giving 2! = 2 completions. Choosing L leaves E and V, giving another 2. Add 4, then consume V.
- Fourth position, target E: only E and L remain. There is no smaller candidate. Consume E.
- Fifth position, target L: only L remains. Add zero and finish.
There are 12 + 4 = 16 arrangements before LEVEL. Its one-based rank is therefore 16 + 1 = 17. The final 1 accounts for LEVEL itself, not for another prefix block.
Notice the third-position denominator. After fixing LE, only one copy of each remaining letter exists. Keeping the original 2!2! denominator would incorrectly divide those two-letter completion counts.
A small example you can inspect completely
For MAMA, the distinct arrangements in increasing order are AAMM, AMAM, AMMA, MAAM, MAMA and MMAA. MAMA is fifth. This short list is a useful check on the prefix method, not a method to use for long words.
At the first position of MAMA, choosing A instead of M leaves A, M, M: 3!/2! = 3 earlier arrangements. After fixing the real prefix MA, choosing A instead of the third-position M leaves one M, adding 1. Thus the rank is 3 + 1 + 1 = 5.
There are two identical As initially, but choosing A at the first position creates just one candidate prefix. Counting that block twice would treat identical letters as distinguishable objects and inflate the rank.
A reliable working table
Use columns for position, fixed prefix, remaining counts, smaller candidate and completion count. Put each smaller candidate on a separate row. This makes it easier to see whether a letter was restored before trying the next candidate.
Never count a candidate whose available count is zero. Never remove the actual target letter before testing alternatives at that position. Those alternatives replace it, so they must start from the same pool of available letters.
The counted blocks do not overlap. A word whose first difference occurs at position one cannot also have its first difference at position three. This is why the block counts are added rather than multiplied together.
Before finishing, check that the target uses exactly the supplied multiset and that the rank is positive. For short practice words, listing distinct arrangements can independently check the answer. For longer words, a careful prefix table is more practical.
Frequently asked questions
Why do we add 1 after counting earlier arrangements?
The count gives the number strictly before the target. With ranks starting at 1, the target occupies the next place. A zero-based index would equal the earlier count instead.
Do repeated copies give separate smaller-letter choices?
No. Try each distinct smaller available letter once. Its remaining repeated copies are handled by the factorial denominator in the completion count.
Can the repeated-letter denominator stay unchanged?
No. Recalculate it after the candidate prefix has been fixed. A letter that occurred twice initially may occur only once, or not at all, in the remaining suffix.
Are only meaningful dictionary words included?
Not in this exercise convention. All distinct arrangements are ordered alphabetically. A question restricted to real dictionary entries would require a specified dictionary and a different search.
Sources and practice scope
SATHEE's permutations material supports counting arrangements with repeated objects. A Mathematics Stack Exchange discussion illustrates prefix counting for duplicate characters. The LEVEL and MAMA calculations here were checked independently.
Related articles
- Singular Matrix Parameters: Find Every Real Value of k
- Arithmetic Progression Word Problems: Method with Worked Examples
- Cubes and Dice: Method with Worked Examples
- Quadratic Word Problems: Method with Worked Examples
- Calendar Odd Days: Method with Worked Examples
Explore related tuition services: maths tuition · home tuition · online tuition