Answered step by step
Verified Expert Solution
Question
1 Approved Answer
vector SquareRectangle(int n, int q, vector &a, vector > &b) { // Write your code here. } solve this question Problem statement Send feedback Ninja
vector
// Write your code here.
} solve this question
Problem statement Send feedback Ninja has an array 'A' of N integers. He has to perform 'Q' operations with that array. The operations are of two types: - 0X : add an integer X to the array. - 1X : remove integer X from the array I t is guaranteed that X exists in the array). After each operation, using the numbers in the array as the lengths of the sides of a rectangle or a square, you have to tell him whether he can make at least one square and one rectangle. There is no condition on the adjacent sides of the rectangle; they can be different or equal, but the opposite side needs to be equal. Return an array of integers, where each element represents an operation. The element will be ' 1 ' if it is possible to make a rectangle and a square after that operation; otherwise, it will be ' 0 '. Example: N=6A=[1,1,1,2,1,1]Q=3C=[[0,2],[0,1],[1,1]] The first line contains two space-separated integers, ' N ' and ' Q ', which denote the array 'A' length and the number of operations, respectively. The second line will contain the 'N' spaced integers denoting the array 'A' values. Next, 'Q' lines contain two space-separated integers denoting the type of operation and the integer ' X ' defined in the problem, respectively. Output format: Return an array of length ' Q ' in which the ith index denotes the answer of the ith operation. Consider 0-based indexing. Note: You don't need to print anything. It has already been taken care of. Just implement the given function. Constraints: 1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started