6 kyu
Integer reduction
283 of 621KenKamau
Description:
In this Kata, you will be given two integers n
and k
and your task is to remove k-digits
from n
and return the lowest number possible, without changing the order of the digits in n
. Return the result as a string.
Let's take an example of solve(123056,4)
. We need to remove 4
digits from 123056
and return the lowest possible number. The best digits to remove are (1,2,3,6)
so that the remaining digits are '05'
. Therefore, solve(123056,4) = '05'
.
Note also that the order of the numbers in n
does not change: solve(1284569,2) = '12456',
because we have removed 8
and 9
.
More examples in the test cases.
Good luck!
Algorithms
Similar Kata:
Stats:
Created | Nov 4, 2017 |
Published | Nov 6, 2017 |
Warriors Trained | 1637 |
Total Skips | 38 |
Total Code Submissions | 3466 |
Total Times Completed | 621 |
JavaScript Completions | 188 |
Python Completions | 283 |
Ruby Completions | 157 |
Haskell Completions | 29 |
Total Stars | 61 |
% of votes with a positive feedback rating | 95% of 119 |
Total "Very Satisfied" Votes | 109 |
Total "Somewhat Satisfied" Votes | 9 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 4 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |