package
0.0.0-20240615115840-a222ecda5fb5
Repository: https://github.com/koykov/algoexpert.io.git
Documentation: pkg.go.dev
# README
Best Digits
Category: Stacks
Difficulty: Medium
Description
Write a function that takes a positive integer represented as a string
number
and an integer numDigits
.
Remove numDigits
from the string so that the number represented
by the string is as large as possible afterwards.
Note that the order of the remaining digits cannot be changed. You can assume
numDigits
will always be less than the length of number
and greater than or equal to 0.
Sample Input
number = "462839"
numDigits = 2
Sample Output
"6839" // remove digits 4 and 2
Optimal Space & Time Complexity
O(n) time | O(n) space - where n is the length of the input string