- 0
Notifications Mark All Read
- Login
- Get Prime
Problem 55
Access Denied!
To view this page you have to login first
Login here -
Trivia
Did you know 1 million people use PrepInsta everyday?
Notifications Mark All Read
To view this page you have to login first
Login here -
Did you know 1 million people use PrepInsta everyday?
#include
using namespace std;
int n;
string s;
int main()
{cin>>n;
cin>>s;
int i,total=0,valley=0,count=0;
for(i=0;i<n;i++)
{if(s[i]=='u')
{total++;}
else
{if(total==0)
{valley++;}
total–;}
}
cout<<valley;
return 0;
}
#c++ code
/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press “Run” button to compile and execute it.
*******************************************************************************/
#include
#include
int main()
{
int n,x,y,z,v=-1,s=0;
char a[10];
scanf(“%d”,&n);
for(int i=0;i<n;i++)
{
scanf("%c",&a[i]);
}
for(int i=0;i<n;i++)
{
if(a[i]=='U')
{
s++;
}
else
{
if(s==0)
{
v++;
}
s–;
}
//printf("%c",a[i]);
}
printf("%d",v);
return 0;
}
#include
#include
int main()
{
int n,i,v=0,s=0;
char arr[15];
gets(arr);
n=strlen(arr);
for(i=0;i<n;i++)
{
if(arr[i]=='U')
s++;
else
{
if(s==0)
{
v++;
}
s–;
}
}
printf("%d\n",v);
return 0;
}