Skip to content
Programmingoneonone - Logo
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Computer System Architecture
    • Microprocessor
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
    • 100+ C++ Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
      • Data Structures Solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone - Logo
Programmingoneonone

HackerEarth Minimum AND xor OR problem solution

YASH PAL, 31 July 202413 February 2026
In this HackerEarth Minimum AND xor OR problem solution, You are given an array A of N integers. Determine the minimum value of the following expression for all valid i,j:
 
(Ai and Aj) xor (Ai or Aj), where i != j.
 
 
HackerEarth Minimum AND xor OR problem solution

 

 

HackerEarth Minimum AND xor OR problem solution.

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
ll t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
ll a[n];
for(ll i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
ll ans = INT_MAX;
for(ll i=0;i<n-1;i++)
{
ans = min(ans, a[i]^a[i+1]);
}
cout<<ans<<"n";
}
return 0;
}
 
 
 
coding problems solutions HackerEarth HackerEarth

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy
  • DMCA

Practice

  • Java
  • C++
  • C

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes