Given a string of digits, remove leading zeros from it.
Input : 00000123569 Output : 123569 Input : 000012356090 Output : 12356090
1) Count leading zeros.
2) Use StringBuffer replace function to remove characters equal to above count.
This article is contributed by Mr. Somesh Awasthi. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Trim (Remove leading and trailing spaces) a string in Java
- How to remove all white spaces from a String in Java?
- Remove all non-alphabetical characters of a String in Java
- Remove extra delimiter from a String in Java
- Remove a given word from a String
- LinkedHashSet remove() method in Java
- LinkedBlockingDeque remove() method in Java
- IdentityHashMap remove() Method in Java
- ConcurrentSkipListSet remove() method in Java
- ArrayBlockingQueue remove() method in Java
- Remove all elements from the ArrayList in Java
- ArrayDeque remove() Method in Java
- HashSet remove() Method in Java
- WeakHashMap remove() method in Java
- TreeSet remove() Method in Java
- LinkedList remove() Method in Java
- CopyOnWriteArraySet remove() method in Java
- TreeMap remove() Method in Java
- How to remove an element from ArrayList in Java?
- Dictionary remove() Method in Java
Improved By : Sanjeev Kumar Jha