Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • IoT ? Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone

HackerEarth Modify Sequence problem solution

YASH PAL, 31 July 2024
In this HackerEarth Modify Sequence problem solution Suppose we have a sequence of non-negative integers, Namely a_1, a_2, … ,a_n. At each time we can choose one term a_i with 0 < i < n and we subtract 1 from both a_i and a_i+1. We wonder whether we can get a sequence of all zeros after several operations.
HackerEarth Modify Sequence problem solution

HackerEarth Modify Sequence problem solution.

#include <iostream>
using namespace std;

int main()
{

int n,s1=0,s2=0;
cin>>n;
int a[n];

for(int i=0;i<n;i++)

{
cin>>a[i];
}

for(int i=0;i<n;i++)

{
if (i%2==0)

{
s1=s1+a[i];
}

else

{
s2=s2+a[i];
}

}

if (s1==s2)

{
cout<<"YES";
}
else
{
cout<<"NO";
}

}
coding problems solutions

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes