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

Stats:

CreatedNov 4, 2017
PublishedNov 6, 2017
Warriors Trained1637
Total Skips38
Total Code Submissions3466
Total Times Completed621
JavaScript Completions188
Python Completions283
Ruby Completions157
Haskell Completions29
Total Stars61
% of votes with a positive feedback rating95% of 119
Total "Very Satisfied" Votes109
Total "Somewhat Satisfied" Votes9
Total "Not Satisfied" Votes1
Total Rank Assessments4
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • KenKamau Avatar
  • smile67 Avatar
  • Voile Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad