Stack: April POTD
Suyash Awathe
Serving Notice Period l Exploring Opportunity Software Engineer @ Virtusa l Spring Boot | REST l Microservices | Data Structures and Algorithm I System Design | Oracle Java Certified Associate SE8
Question: Remove K Digits -(Medium)
Given string num representing a non-negative integer num, and an integer k, return the smallest possible integer after removing k digits from num.
Input: num = "1432219", k = 3
Output: "1219"
Explanation: Remove the three digits 4, 3, and 2 to form the new number 1219 which is the smallest.
Intuition:
Apporach:
Code:
Time Complexity : O(n)
Space Complexity: O(n) ,as we use stack to store characters.