Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • 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
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerEarth Divisible problem solution

YASH PAL, 31 July 202413 February 2026
In this HackerEarth Split houses problem solution, you are given an array A of size N that contains integers. Here, N is an even number. You are required to perform the following operations:
  1. Divide the array of numbers in two equal halves
  2. Note: Here, two equal parts of a test case are created by dividing the array into two equal parts.
  3. Take the first digit of the numbers that are available in the first half of the array (first 50% of the test case)
  4. Take the last digit of the numbers that are available in the second half of the array (second 50% of the test case)
  5. Generate a number by using the digits that have been selected in the above steps
Your task is to determine whether the newly-generated number is divisible by 11.
 
 
hackerEarth Divisible problem solution
 
 

HackerEarth Divisible problem solution.

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << 'n'
int main(int argc, char const *argv[]) {

return 0;
}

 

 

second solution

#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vll vector<ll>
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin>>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define fulll(v) v.begin(),v.end()
#define vecin(n, v) for(ll i=0; i<n;i++) cin>>v[i];
#define vecout(n, v) for(ll i=0; i<n;i++) cout<<v[i]<<" "; cout<<endl;
#define rep(i, s, n) for(ll i=(ll)s;i<(ll)n;i++)
#define rrep(i, s, n) for(ll i=(ll)s;i>=(ll)n;i--)
#define pb push_back
#define mkp make_pair
#define endl "n"
#define test cout<<"test line"<<endl;
#define swapper void swap(ll *a, ll *b){ll t=*a;*a=*b;*b=t;}
#define pll pair<ll,ll>
#define vpll vector<pll >
#define mod 1000000007
#define INF 0x3f3f3f3f
#define MAX 100005

using namespace std;

int main(){

llin(n);
assert(n>=1 && n<=100000);
ll se=0, so=0;
rep(i,0,n){
string s;
cin>>s;
stringstream check(s);
ll val;
check>>val;
assert(val>=1 && val<=100000);
if(i<n/2)
i&1?so+=s[0]-'0':se+=s[0]-'0';
else
i&1?so+=s.back()-'0':se+=s.back()-'0';
}
if(se==so)
cout<<"OUI";
else
cout<<"NON";
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

Practice

  • Java
  • C++
  • C

Follow US

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