Toggle Bulbs
You are given n bulbs, numbered from 1 to n. Initially all the bulbs are turned off.Input Format
You have to perform 2 types of operations:-
1. Toggle all bulds numbered between A to B.Here toggle mean turn on bulbs to off and off bulbs to on.This is represented by 1 A B.
2. Count how many bulbs numbered between A to B are on.This is represented by 2 A B.
First line contains two integers n and q.Output Format
Following q lines contains queries of format either 1 A B or 2 A B.
Print count of bulbs for query type 2 A B.Question Video
1. 1 <= n <= 10^5Sample Input
2. 1 <= q <= 10^5
3. 1 <= A <= B <= n
4 7Sample Output
2 1 4
1 2 3
2 1 2
2 1 1
1 1 4
2 1 4
2 4 4
0
1
0
2
1
-
Asked in Companies
-
Related Topics
Video Solution
Code Solution
{ }
{ }
Run