The Deaf Rats of Hamelin
The Deaf Rats of Hamelin
Approach
find pattern
Count the rats who looking in the opposite direction of Pied Piper
solve the problem
split based on 'P' as 'left', 'right'
remove empty space of 'left', 'right'
split left and right side every 2 characters through RegExp for distinguishing rats
check left side who seeing left side because 'left side' means pied piper's 'left side' which means rats must-see 'pide piper' and the one who does not look right side that's the target
check right side who seeing right side because 'right side' means pied piper's 'right side' which means rats must-see 'pide piper' and the one who does not look left side that's the target
return process-4 plus process-5 result
Solution
Last updated
Was this helpful?