Toby and his game SOLUTION TOBY

Toby and his game SOLUTION TOBY

Toby has discovered a game to engage himself.The game is this way: 
 
You are in an organize framework at first at (0,0) and you are given a grouping of steps which lead to your destination.The steps are given as headings: ‘U’ ,’D’ , ‘L’ and ‘R’ for up, down, left and right respectively.If you are at position (x,y) at that point: 
 
U:move to (x,y+1) 
 
D:move to (x,y-1) 
 
L:move to (x-1,y) 
 
R:move to (x+1,y) 
 
The arrangement is given as a string ‘s’ of characters where si (1≤i≤N) is one of the bearing character as referenced above.An case of a grouping of steps is: UULRUDR 
 
The objective as per this string is (1,2). 
 
You need to eliminate most extreme number of characters from the string with the end goal that the subsequent string prompts a similar objective as in the past. 
 
For instance in the model above we can eliminate characters at positions 1,3,4,6 and the subsequent way will be UUR which will prompt a similar objective i.e (1,2).so we diminished the quantity of steps by 4,and this is our score. You have to get greatest score. 
 
Information: 
 
First line will contain T, number of testcases. At that point the testcases follow. 
 
First line of each testcase contains a solitary whole number N,size of string. 
 
Second line of testcase contains a string s of size N. 
 
Yield: 
 
For each testcase, yield a solitary line containing the most extreme score conceivable. 
 
Limitations 
 
1≤T≤1000 
 
1≤N≤105 
 
Test Input: 
 
 
 
ULUDLLU 
 
 
RUUR 
 
 
LRLR 
 
Test Output: 
 
 
 
 
Clarification: 
 
experiment 1: The last objective in the wake of moving as per the grouping is (- 3,2). 
 
One path is to eliminate characters at positions 3,4 and the subsequent string will be ULLLU objective despite everything remains (- 3,2). 
 
experiment 2: No character can be taken out for this situation.
 
THANKS FOR JOINING THE LIVE 
SOLUTIONS WILL BE SHARED HERE SOON

March Long Challenge 2021 Solutions

April Long Challenge 2021 Solutions

Codechef Long Challenge Solutions

February Long Challenge 2021

1. Frog Sort Solution Codechef

2. Chef and Meetings Solution Codechef

3. Maximise Function Solution Codechef

4. Highest Divisor Solution Codechef

5. Cut the Cake Challenge Solution Codechef

6. Dream and the Multiverse Solution Codechef

7. Cell Shell Solution Codechef

8. Multiple Games Solution Codechef

9. Another Tree with Number Theory Solution Codechef

10. XOR Sums Solution Codechef

11. Prime Game Solution CodeChef

12. Team Name Solution Codechef

January Long Challenge 2021

November Challenge 2020 SOLUTION CodeChef

October Lunchtime 2020 CodeChef SOLUTIONS

RELATED :

Related :

Related :

Leave a Comment

close
error: Content is protected !!