Question: Amazon , Recent Online Assessment Questions | Amazon Developing Service | 14th August 2023
2
Entering edit mode

ADD COMMENTlink 16 months ago PoGo 2.4k
Entering edit mode
0

hey I also want to apply for the same, which Oa is this and where to apply pls share

 

 
ADD REPLYlink 16 months ago
Mayank Rawat
• 0
1
Entering edit mode

solution

 

void solve()
{
int n;
cin>>n;
set<int> s;
f(i,n)
{
    int x;
    cin>>x;
    s.insert(x);
}
int sz=s.size();
int ans=0;
for(int i=0;i<=n;i++)
{
   ans+=(n-i)*min(i+1,sz);
}
cout<<ans<<endl;

}
int main()
{
   
   solve();      
}

 

ADD COMMENTlink 16 months ago suryansh jaiswal • 370

Login before adding your answer.

Similar Posts
Loading Similar Posts