Bit Magic | Hindi | GFG POTD | C++ | Java | Code Kar Lo

1 Просмотры
Given an integer array arr[] of size n which contains only 1 and 0. Your task is to make the array perfect. An array is said to be perfect if for each i from 0 to n-1 arr[i]==arr[n-1-i] is satisfied.

To Make the array perfect you are allowed to do the following operation :

In one operation you can choose two different indexes i and j and set value of both arr[i] and arr[j] to arr[i]^arr[j].

Your task is to make the array perfect in minimum possible number of operations and return the number of operations.

Note: 0-based indexing is used.

0:00 Introduction
0:15 Problem Statement
1:18 White Board Explanation
4:38 Complexity Analysis
5:00 C++ Code
6:35 Java Code

gfg potd
gfg potd today
gfg problem of the day

My DSA Journey:-

How to Earn By GFG Articles:-

Problem Link:-

Code Link:-

Playlist Link:-



My GFG Profile:-

#dsa #datastructures #algorithm #gfg #potd #coding #array #strings #tree #binarysearchtree #codekarlo #dynamicprogramming
Язык программирования C++
Комментариев нет.