There is a binary string consisting of characters '0' and '1'. Initially, Bob is facing East when he starts reading the binary string. When he sees a '0', he turns $$$90^\circ$$$ to his right. When he sees a '1', he turns $$$90^\circ$$$ to his left.
The four directions are as follows: East is denoted by 'E', West by 'W', North by 'N', and South by 'S'.
After reading the entire string, which direction will Bob face?
The first line contains an integer $$$t$$$ $$$(1 \leq t \leq 10^{2})$$$ $$$-$$$ the number of test cases in the input.
Then $$$t$$$ test cases follow.
The first line of the test case contains one integer $$$n$$$ $$$( 1 \leq n \leq 10^{5} )$$$.
The second line of the test case contains a string $$$s$$$ of $$$n$$$ characters, consisting only '0' and '1'.
It is guaranteed that the sum of the values of $$$n$$$ for all test cases in the input does not exceed $$$2\cdot10^{5}$$$.
For each test case, Print a single character — the direction Bob is facing after reading the string.
3 4 1010 5 00000 3 111
E S S
In the first test, for the first two moves, Bob turns $$$90^{\circ}$$$ left and then turns $$$90^{\circ}$$$ right. So, he is back to his initial orientation. Again he repeats the same for the other two moves. So his final direction is East.
In the second test, After $$$4$$$ moves Bob is back to his initial orientation, and after the next $$$90^{\circ}$$$ right move, he will be facing South.
You are given an array of $$$n$$$ integers. You want to make all the numbers in this array as odd. In one operation you can select two indices $$$i$$$ and $$$j$$$ $$$(i \neq j)$$$ and replace $$$a_i$$$ with $$$(a_i + a_j)$$$.
Find the minimum number of operations needed to make all the numbers odd. If there is no way to do it, then print $$$-1$$$.
The first line contains an integer $$$t$$$ $$$(1 \leq t \leq 10^{2})$$$ — the number of test cases in the input.
Then $$$t$$$ test cases follow.
The first line of the test case contains one integer $$$n$$$ $$$( 1 \leq n \leq 2\cdot10^{5} )$$$.
The second line of the test case contains $$$n$$$ space-separated integers $$$a_i$$$ $$$( 1 \leq a_i \leq 10^{6} )$$$$$$-$$$$$$a_i$$$ is the $$$i^{th}$$$ number.
It is guaranteed that the sum of $$$n$$$ does not exceed $$$2\cdot10^{5}(\sum n \leq 2\cdot10^{5})$$$.
For each test case, If it is impossible to make all the numbers odd then print $$$-1$$$, otherwise print the minimum number of operation needed to make all the numbers odd.
4 4 1 4 3 2 5 1 4 3 2 5 6 1 2 6 5 3 4 3 4 2 6
2 2 3 -1
In the first test
Operation 1: replace $$$a_2$$$ with $$$(a_1 + a_2)$$$. The new array is $$$a = [1, 5, 3, 2]$$$.
Operation 2: replace $$$a_4$$$ with $$$(a_3 + a_4)$$$. The new array is $$$a = [1, 5, 3, 5]$$$.
In the fourth test, it is impossible to make all the numbers as odd.
You are given the programming skill of $$$n$$$ students. The programming skill of $$$i^{th}$$$ student is $$$a_i$$$.
You are given the duty of making teams for a programming competition. The skill level of a team is defined as the sum of the skills of the students in that team. The skill level of the team with only one student is the same as the skill of that student.
A team can have at most 2 students and the skill level of a team must be at least $$$k$$$.
Find the maximum number of teams that you can form under the given constraints.
Each student can be part of at most one team and it is possible that some students are not selected in any team.
The first line contains an integer $$$t$$$ $$$(1 \leq t \leq 10^{2})$$$ — the number of test cases in the input.
Then $$$t$$$ test cases follow.
The first line of the test case contains two integer $$$n$$$ and $$$k$$$ $$$( 1 \leq n \leq 2\cdot10^{5}, 1 \leq k \leq 10^{6} )$$$ $$$-$$$ number of students and the minimum sum of skills of the members of a team.
The second line of the test case contains $$$n$$$ space-separated integers $$$a_i$$$ $$$( 1 \leq a_i \leq 10^{6} )$$$$$$-$$$$$$a_i$$$ is the programming skill of $$$i^{th}$$$ student.
It is guaranteed that the sum of $$$n$$$ does not exceed $$$2\cdot10^{5}(\sum n \leq 2\cdot10^{5})$$$.
For each test case, Output the maximum number of teams you can form.
3 5 8 9 3 4 4 5 5 8 5 2 3 5 1 3 6 7 6 8
3 1 3
In the first test, you can make at most 3 teams.
1st team: $$$1^{st}$$$ student.
2nd team: $$$2^{nd}$$$ and $$$5^{th}$$$ student.
3rd team: $$$3^{rd}$$$ and $$$4^{th}$$$ student.
In the third test, you can make 3 teams using one student each.
Alice and Bob are playing a game.
First Alice will choose two integers $$$a$$$ and $$$b$$$ $$$(a \leq b)$$$. Then Bob will take two integers $$$c$$$ and $$$d$$$ $$$(1 \leq c \leq a , 1 \leq d \leq b)$$$.
Score of Alice will be ($$$a \oplus b$$$) and score of Bob will be ($$$c \oplus d$$$), where $$$\oplus$$$ denotes the bitwise xor operation.
If the score of Bob is strictly greater than the score of Alice then Bob wins, otherwise Alice wins.
You know the two integers $$$a$$$ and $$$b$$$ that Alice chose. Determine if it is possible to choose some $$$c$$$ and $$$d$$$ for Bob to win.
The first line contains an integer $$$t$$$ $$$(1 \leq t \leq 10^{2})$$$ — the number of test cases in the input.
Then $$$t$$$ test cases follow.
Each test case is a line containing two integers $$$a$$$ and $$$b$$$ $$$(2 \leq a,b \leq 10^{6}, a \leq b)$$$.
For each test case, If Bob has a winning strategy print Yes, otherwise No.
You can print each character in any case.
3 2 2 2 4 6 10
Yes No Yes
In the first test, the score of Alice is $$$0$$$. Bob can choose $$$c=1$$$ and $$$d=2$$$ to get a score of $$$3$$$ to win.
In the second test, we can show that whatever Bob chooses, he will always lose.
You are given a string which is the hint of a password. Given string only consist of character '1' to '9' and '-'.
You can replace '-' by any digit from '1' to '9'.
Find the number of ways to make a password by replacing all '-' characters to some digit, such that the digits of the password are in non-decreasing order.
If it is impossible to make the digits of the string in non-decreasing order, print "0" otherwise since the answer can be very large, print the answer modulo $$$10^{9} + 7$$$.
The sequence a is called non-decreasing if $$$a_1 \leq a_2\leq\dots\leq a_n$$$ holds, where $$$n$$$ is the length of the sequence.
The first line contains an integer $$$t$$$ $$$(1 \leq t \leq 10^{2})$$$ $$$-$$$ the number of test cases in the input.
Then $$$t$$$ test cases follow.
The first line of the test case contains one integer $$$n$$$ $$$( 1 \leq n \leq 10^{5} )$$$.
The second line of the test case contains a string $$$s$$$ of $$$n$$$ characters, consisting only '1' to '9' and '-'.
It is guaranteed that the sum of the values of $$$n$$$ for all test cases in the input does not exceed $$$10^{5}$$$.
For each test case, If it is impossible to make the digits of the string in non-decreasing order, print "0" otherwise print the number of ways modulo $$$10^{9} + 7$$$
5 5 1---2 3 3-4 7 2--43-4 8 1---23-4 1 -
4 2 0 8 9
In the first test, we have four ways to fill '-' characters $$$111$$$, $$$112$$$, $$$122$$$, $$$222$$$.
In the second test, we have two ways to fill the '-' character, $$$3$$$ or $$$4$$$.
In the third test, it is impossible to convert this into a valid string.
Steve has $$$k$$$ dollars and he wants to buy some items from a shop. This shop has $$$n$$$ elements arranged in a row. For a given $$$i (1 \leq i \leq n)$$$, the rate of the $$$i^{th}$$$ item is $$$a_i$$$.
The shop has a weird rule. A customer can only buy the items that form a contiguous segment, that is, they will choose two integers $$$l$$$ and $$$r$$$ $$$(1 \leq l \leq r\leq n)$$$ and buy all the items in the subsegment $$$[l,r]$$$.
A subsegment $$$[l, r] \: (l ≤ r)$$$ of array $$$a$$$ is the sequence $$$a_l, a_{l + 1}, \dots, a_r$$$.
Today the shop has a special offer. If a customer buys an item of some rate, then all other items in the selected range with the same rate can be bought for free.
Find the maximum number of items that Steve can buy with $$$k$$$ dollars by visiting the shop only once.
The first line contains an integer $$$t$$$ $$$(1 \leq t \leq 10^{2})$$$ $$$-$$$ the number of test cases in the input.
Then $$$t$$$ test cases follow.
The first line of the test case contains two integers $$$n$$$ and $$$k$$$ $$$(1 \leq n \leq 2\cdot10^{5},1 \leq k \leq 10^{6})$$$$$$-$$$ number of items in the shop and amount of dollars Steve has.
The second line of the test case contains $$$n$$$ space-separated integers $$$a_i$$$ $$$(1 \leq a_i \leq 10^{6})$$$$$$-$$$ $$$a_i$$$ is the $$$i^{th}$$$ item's rate as dollar.
It is guaranteed that the sum of $$$n$$$ does not exceed $$$2\cdot10^{5}(\sum n \leq 2\cdot10^{5})$$$.
For each test case, Print the maximum number of items Steve can buy.
3 8 5 1 3 2 2 2 3 1 3 8 6 1 1 2 2 2 3 3 3 5 5 1 1 2 3 3
5 8 3
In the first test case, Steve can get the items in the range $$$a[2\dots6]$$$ by buying the $$$2^{nd}$$$ and $$$3^{rd}$$$ items.
In the second test, Steve can get all the items just by buying the $$$1^{st}$$$, $$$3^{rd}$$$ and $$$6^{th}$$$ items.