Want to try solving this problem? You can submit your code online if you log in or register.
After the success of your latest research project in mythical DNA, you have gained the attention of a most diabolical creature: Medusa.
Medusa has snakes instead of hair. Each of her snakes' DNA is represented by an uppercase string of letters. Each letter is one of S, N, A, K or E.
Your extensive research shows that a snake's venom level depends on its DNA. A snake has venom level x if its DNA:
For example, a snake with venom level 1 has DNA SNAKE, while a snake that has venom level 3 has DNA SSSNNNAAAKKKEEE. If a snake's DNA does not fit the format described above, it has a venom level of 0.
Medusa would like your help making her snakes venomous, by deleting zero or more letters from their DNA. Given a snake's DNA, can you work out the maximum venom level this snake could have?
Your program should output a single integer: the maximum venom level the snake could have, after you delete some (possibly none) of the letters from its DNA.
17 KSEESNANNAAKNKESE
2
22 SSSSNNNAAAAKKKKEEEEEEE
3
15 SNAKESNAKESNAKE
1
6 KANSAS
0
The letters that are deleted in each case are underlined below:
For all cases, 5 ≤ N ≤ 100,000. Additionally:
Privacy
statement
© Australian Mathematics Trust 2001-2023
Page generated: 25 March 2023, 7:46pm AEDT