n this Kata, you will be given a string with brackets and an index of an opening bracket and your task will be to return the index of the matching closing bracket. Both the input and returned index are 0-based except in Fortran where it is 1-based. An opening brace will always have a closing brace. Return -1 if there is no answer (Haskell return Nothing, Fortran: return 0)
For example
solve("((1)23(45))(aB)", 0) = 10 // the opening brace at index 0 matches the closing brace at index 10
solve("((1)23(45))(aB)", 1) = 3
solve("((1)23(45))(aB)", 2) = -1 // there is no opening bracket at index 2, so return -1
solve("((1)23(45))(aB)", 6) = 9
solve("((1)23(45))(aB)", 11) = 14
solve("((>)|?(*'))(yZ)", 11) = 14
'매일매일개발 > Codewars' 카테고리의 다른 글
codewars #53 FIXME: Hello (6kyu) (0) | 2018.05.31 |
---|---|
codewars #52 Are they the "same"? (6kyu) (0) | 2018.05.30 |
codewars #50 String -> N iterations -> String (5kyu) (0) | 2018.05.28 |
codewars #49 Playing with digits (6kyu) (0) | 2018.05.25 |
codewars #48 A Rule of Divisibility by 13 (6kyu) (0) | 2018.05.24 |