about | help | code help+videos | done | prefs |
Write a method that returns the number of characters that a different when you compare the two strings 'str1' and 'str2'. Characters count as different each time you have characters that do not exactly match in the same positions in the two strings. Upper-case and lower-case letters are different so 'A' and 'a' count as not matching. Also, if one of the strings is longer than the other, all of those extra characters have no character to match with, so they also count as not matching. For example, if 'str1' is "abCdeFghij" and 'str2' is "abcDeF", you would return 6. The reason you would return 6 is that the 'C' in the first string does not match the 'c' in the second string. The same thing is true with the 'd' and 'D'. The other 4 non-matches come from the 4 extra characters in the first string. Look at the test data for more examples. test2024_12_12_APP1SLHL_countDifferences("haeuiogh89tay3489ty", "634") → 19 test2024_12_12_APP1SLHL_countDifferences("Once upon a time, there was a programmer named 'Chad'.", "Chad had a dad. But Chad's dad was not a programmer.") → 50 test2024_12_12_APP1SLHL_countDifferences("ajhfduweioaughugdfhkgjhkladh;gda", "jfioasheiogyhao;ehyto;iya;gh") → 28 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy