Problem Statement:
In an Amazon analytics team, the Analysts collectively have a preference for the number zero and a disapproval towards negative numbers. Their objective is to determine the maximum number of zeroes achievable after performing a series of operations (possibly zero) on an array, all while avoiding negative values.
Formally, given an array sequenceData of size n of positive integers, the Analysts can perform the following operation any number of times (possibly zero):
Find the maximum number of zeroes that the array sequenceData can contain after performing any (possibly zero) number of operations on the array.
Problem Statement:
Amazon has introduced an innovative tool to explore the fascinating world of "Word Conjugates", allowing users to analyze strings consisting of only characters: 'a', 'b', 'c', and 'd'.
The concept of conjugates follows a unique pairing mechanism where 'a' pairs with 'b', 'c' pairs with 'd' and vice-versa. As a result, there are only four possible valid conjugate pairs: ('a', 'b'), ('b', 'a'), ('c', 'd'), and ('d', 'c').
The objective is to calculate the total number of valid substrings in a given string s.
A string is considered valid if:
using namespace std;
void solve(){
int n; cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++) cin>>a[i];
vector<int>pre(n,1e9);
pre[0]=a[0];
int cnt_zeros=1;
for(int i=1;i<n;i++){
pre[i]=min(a[i],pre[i-1]);
if(a[i]<=pre[i]){
cnt_zeros++;
}
}
cout<<cnt_zeros<<endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}