TopH Little Subarray Sum Solution

Solve in C++:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,a,b,ar[1001],s=0;
    while(cin>>n>>a>>b)
    {
        for(i=0; i<n; i++)
        {
            cin>>ar[i];

        }
        for(i=a;i<=b;i++)
    {
        s=s+ar[i];
    }
    cout<<s<<endl;
    s=0;
}
}

No comments

Most View Post

Recent post

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.