Day 23 of 100 day of code

ยท

1 min read

Today I solved a question on CodeChef

question

#include <bits/stdc++.h>
using namespace std;

int solve(string s){
  int n = s.size();
  int cnt =0;
  for(int i =0;i<n-1;i++){
      if(s[i]=='<'&& s[i+1]=='>'){
        cnt++;
      }
  }
  return cnt;
}

int main(){
  int t;
  cin>>t;
  while(t--){
    string s;
    cin>>s;
    int ans = solve(s);
    cout<<ans<<endl;
  }
}
ย