6 kyu
String reduction
358 of 896KenKamau
Description:
In this Kata, we are going to see how a Hash (or Map or dict) can be used to keep track of characters in a string.
Consider two strings "aabcdefg"
and "fbd"
. How many characters do we have to remove from the first string to get the second string? Although not the only way to solve this, we could create a Hash of counts for each string and see which character counts are different. That should get us close to the answer. I will leave the rest to you.
For this example, solve("aabcdefg","fbd") = 5
. Also, solve("xyz","yxxz") = 0
, because we cannot get second string from the first since the second string is longer.
More examples in the test cases.
Good luck!
Fundamentals
Similar Kata:
Stats:
Created | Nov 2, 2017 |
Published | Nov 3, 2017 |
Warriors Trained | 1669 |
Total Skips | 65 |
Total Code Submissions | 4822 |
Total Times Completed | 896 |
JavaScript Completions | 358 |
Python Completions | 497 |
Ruby Completions | 54 |
Haskell Completions | 21 |
Total Stars | 37 |
% of votes with a positive feedback rating | 91% of 230 |
Total "Very Satisfied" Votes | 196 |
Total "Somewhat Satisfied" Votes | 28 |
Total "Not Satisfied" Votes | 6 |
Total Rank Assessments | 4 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |