Find all balanced k in a permutation | Microsoft Interview Question