Given an input string N consisting of numerals and separators (, ) in the Indian Numeric System, the task is to print the string after placing separators(, ) based on International Numeric System.
Input: N = “12, 34, 56, 789”
Output: 123, 456, 789
Input: N = “90, 05, 00, 00, 000”
Output: 90, 050, 000, 000
- Remove all the separators (, ) from the string.
- Iterate from the end of the string and place a separator(, ) after every third number.
- Print the result.
Below is the implementation of the above approach:
Related article: Convert the number from International system to Indian system
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.