Sherlock and the Valid String | HackerRank (Python)

Published: 21 June 2021
on channel: Glitched Failure
239
3

CORRECTION: For the last check (10:38), the logic should also include a check that the count of counts for the LARGER number is 1. This is because we can only remove a character, not add one - so checking the absolute difference between the counts is not enough. For example, the string "aabbbcccddd" or {a:2, b:3, c:3, d:3} should be invalid. I've included this correction in my code (see link below).
CORRECTION: While the solution in the video passes all test cases, the logic could still be improved. Most notably for the case of "abb", which should return "YES". I've updated my solution to cover this case.

Challenge: https://www.hackerrank.com/challenges...

Code: https://gist.github.com/Shaddyjr/b0aa...

Intro: (0:00)
Solution: (1:21)

As a way to improve my coding skills and technical interview prep, I practice HackerRank, Code Wars, and Code Signal problems and solve them live with minimal edits. This allows viewers to see my thought process and problem-solving techniques along with the true struggles I go through when solving these technical coding problems. I also delve into tutorials about building out data structures, algorithms, and various other relevant and practical topics.

I mainly code in JavaScript, Python, and SQL. I also occasionally detour onto other challenges, like those from my own technical interviews, daily coding challenges, or just fun coding puzzles I come across.


Watch video Sherlock and the Valid String | HackerRank (Python) online without registration, duration hours minute second in high quality. This video was added by user Glitched Failure 21 June 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 239 once and liked it 3 people.