00:00

Problem Statement

Input/Output Examples

Visual Explanation

Every Indian unit except the crore holds a value below 100, so one helper for 1–99 names almost everything. A crore count can be larger, so it is spelled with the same method recursively.

Approaches

Both approaches produce identical text. One divides by each unit in turn; the other recurses on the largest unit.

Java Solutions

Each tab is a complete program that runs on Java 17 or later. Both programs print the same output for the same inputs.

Complexity Analysis

Here n is the amount. The number of units, and so the amount of work, grows with the number of digits.

Interview Tips and Recommended Approach

  • Know the grouping. 1,00,000 is a lakh and 1,00,00,000 is a crore; only the last group has three digits.
  • Skip zero parts so 10000000 is "One Crore", not "One Crore Zero Lakh".
  • Handle singular and plural for the currency word.
  • Ask about paise. Decimal amounts need a second part, such as "and Fifty Paise".

Recommended Approach: Divide by Each Unit

Why: it follows the Indian reading order directly and keeps the unit table in one place, so it is easy to extend, for example with paise.