AlgoUniversity
  • Go Back
Discussion
XORing String :

Author

Yash Sahijwani

Difficulty Level : Medium

Submissions : 1453

Asked In : Amazon

Marks :10

: 28 | : 2

You are given a string $$$s$$$ consisting of lowercase Latin letters $$$(a-z)$$$. The score of a string is defined as the XOR of the frequencies of all the distinct letters in the string. You are required to handle two types of queries:

  • 1 L R : Answer the score of the substring from L to R.
  • 2 X Y : Update the character at the position X to the Y$$$_{th}$$$ letter in the English Alphabet

Input

The first line of the input consists of a string $$$s$$$ $$$(1 \leq |s| \leq 10^6)$$$. The second line consists of a single integer $$$q$$$ $$$(1 \leq q \leq 10^6)$$$ $$$-$$$ the total number of queries. Then each of the next $$$q$$$ lines are queries of either of the following two types:

  • 1 L R : $$$(1 \leq L \leq R \leq |s|)$$$
  • 2 X Y : $$$(1 \leq X \leq |s|)$$$ , $$$(1 \leq Y \leq 26)$$$

Output

For each query of type 1, you should output a single integer - the XOR of the frequencies of all distinct characters in that particular substring.

Example

Input
tti
4
2 3 1
1 1 2
2 1 2
1 2 3
Output
2
0

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.