Rahul lucky-unlucky
Submissions: 858   Accuracy:

25.22%

  Difficulty: Basic   Marks: 1

Rahul is a geek. Head is the lucky call for him. You have to make him lucky. You are provided N coins. If the coin is heads facing upwards it means he is lucky else unlucky, your task is to do an operation to make him lucky. Operation allowed is as follows :
Starting from first element, if you find any coin heads facing downwards (Tail), flip the coin at ith index and (i+1)th index.  

Input:
The first line consists of T test cases. Each test case consists of 2 lines. The first line contains an integer N, denoting the number of coins. The second line contains N coins, represented by H or T (denoting head facing upwards and tail facing upwards respectively).

Output:
For each test case, output two lines where first line should contain number of flips, while next line contains indexes where coins have been flipped (starting index from 1). If no coin is flipped, second line prints "-1" (without quotes).

Constraints:
1 <= T <= 103
1 <= N <= 107

Example:
Input:

2
3
H H H

H T H T H
Output: 
0

-1
2
2 3

Explanation:
Testcase2:
Coins at index 2 and 3 needs to be flipped to make Rahul happy.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth
Author: saksham seth


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.