Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



 2964

NEED HELP WITH THIS CODING PROBLEM!!

by cyphur23719 - 29 April, 2022 - 06:43 PM
This post is by a banned member (cyphur23719) - Unhide
213
Posts
5
Threads
3 Years of service
#1
You are given an array A of even length N consisting of non-negative integers. You need to make each element of the array equal to zero, by doing some number of moves (possibly zero).

In a single move, you can choose two integers l and r such that 1 ≤ l ≤ r ≤ N. Let x = A[l] ⊕ A[l+1] ⊕ A[l+2] ... A[r], where ⊕ represents xor operator. Then, replace the whole subarray with x. In other words, assign A[i] = x for l ≤ i ≤ r.

Print the minimum number of moves required to make the entire array zero.

Sample Input:
2
2
2 2
4
7 1 2 0

Sample Output:
1
2
This post is by a banned member (UberFuck) - Unhide
UberFuck  
Godlike
1.557
Posts
375
Threads
5 Years of service
#2
Do your own homework you fucking leech.

[Image: OzJueWr.gif]
This post is by a banned member (Steadfast2201) - Unhide
53
Posts
3
Threads
2 Years of service
#3
I can help bro with problem @Ramzes.
Telegram @Steadfast2201

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 1 Guest(s)