Tomorrow Happy Karwa Chauth from Isolated Study! Study smarter this festive season with IsolatedAI.Try AI free →

Computer science

Computer science

'

\ufeff2
A king has ordered all n women in his kingdom to stand in a row. Some women stand facing the right direction, and some stand facing the left direction, and their directions are depicted using a string k. \ufeffThe king decides to choose one woman from the row to be the queen, and he needs your help in doing so, \ufeffbased on the following criteria:
1. \ufeffAny woman can be chosen to be queen. Once the queen is chosen, all other women must change their direction and stand in the row
the queen. •
2. \ufeffThe best quo
albe the one who will cause the least number of
women to change their dileonen.
0176@ srmist
993800
Find out the position of the best queen and the number of women who will have to change their position to face the best queen.
Input Format
• \ufeffThe first line contains an integer n, \ufeffthe number of women in the row.
• \ufeffThe second line contains a string k of length n, \ufeffwhere \'R\' \ufeffdepicts right and \'L\' \ufeffdepicts left.
ay0176@srmist
+918009938000
3
4
5
6
7
8
9
10
11
12
#include «vector>
#include «iostream> \ufeff#include «algorithm> \ufeffusing namespace std;
int main() ‹
/ \ufeffEnter your code here return 0;
Output Format
Output should display two space-seprated positive integers:
• \ufeffThe position of the best queen (index starting from 1)
• \ufeffThe number of women who will have to change their position to face the best queen.
'

Manu
Manu

Expert Title:TEST

Answer

Student’s rating for this solution:

★ ★ ★ ★ ★ (5/5)

Extracted Transcript from Images

+