Count Special Index Pairs | Google Interview Question