You have two bugs in your code

*for j in range(n-1, -1, -1):*

should be

*for j in range(n-1, 0, -1):*

This is to make sure that j-1 is not negative.

The other bug is for finding the right pair of CS to swap.

Use the following as example: CCSS
The first pair you swap is C*CS*S, then it becomes CSCS
The next pair to swap should be CS*CS*, however, your solution will swap 
*CS*CS instead.

If you are not convinced, you can try the following test
*1*
*4 CCSS*

The expected output should be
*Case #1: 2*

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/73ae79fb-79da-480b-a448-eb0adbcf36fb%40googlegroups.com.

Reply via email to