Your solution has time complexity O(N^2) for each query which is too slow to pass Test set 2
In order to pass test set 2, you need to calculate the number of A to Z in a given prefix. Then use this prefix to calculate the number of A to Z in any given range Then for any given range, check if at most one alphabet has appear odd number of times in this range. The overall complexity should be O(N * 26) for each query. Also checkout analysis for more detailed explanation. -- 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/d133cee6-e8cd-4d3a-9e81-1df10a6753ac%40googlegroups.com.