pratyush2013
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
int pivot(int arr[],int n)
{
int sum=0;
for(int i=0;i<n;i++)
sum+=arr[i];
int tot=0;
for(int i=0;i<n;i++)
{
sum-=arr[i];
if(sum==tot)
return i;
tot+=arr[i];
}
return -1;
}
- pratyush2013 November 13, 2016Comment hidden because of low score. Click to expand.
0
of 0 vote
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
int tot[n];
memset(tot,0,sizeof(tot));
for(int i=0;i<n;i++)
if((i-arr[i]+n)%n>=0)
tot[(i-arr[i]+n)%n]++;
int k=0;
int val=tot[0];
for(int i=0;i<n;i++)
cout<<tot[i]<<" ";
cout<<endl;
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Through dfs
- pratyush2013 November 13, 2016