Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def countDistantPairs(inputString, distance)
- x = 0
- y = 1
- result = 0
- while (x < inputString.length)
- while (y < inputString.length)
- if inputString[x] == inputString[y] and y - x - 1 == distance then
- result = result + 1
- end
- y = y + 1
- end
- x = x + 1
- y = x + 1
- end
- return result
- end
Advertisement
Add Comment
Please, Sign In to add comment