Loading...
Loading...
Loading...
A UPI app shows only the last 4 digits of a linked bank account. Read the account number and print it with every digit except the last 4 replaced by *.
Example 1
Input
9876543210
Output
******3210
Example 2
Input
1234
Output
1234
Exactly 4 digits: nothing is hidden.
Try the problem first. Open one hint at a time.
Keep the number as a String, not a long, so leading zeros are not lost.
The hidden part has length() - 4 stars: "*".repeat(...) builds it.
substring(length() - 4) gives the last 4 digits.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor