Skip to content

Commit

Permalink
chore: solved medium day 12 task
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutosh-3474 committed Apr 14, 2024
1 parent 3bf3dc3 commit a5ae4c7
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion Medium/Day12/Solution.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
// Write Your Code Here
// Write Your Code Here
#include<iostream>
#include<vector>
#include<string>
typedef long long int ll;
#define MOD 998244353
using namespace std;


int main(){
int t;
cin>>t;
while(t--){
string s;
cin>>s;

int n=s.length();
vector<ll> vec(n);
vec[0]=1;
vec[1]= vec[0]+ (s[0]!=s[1]);
for(int i=2; i<n; i++){
if(s[i]!=s[i-1]){
vec[i]=(vec[i-1]+vec[i-2])%MOD;
}else{
vec[i]=vec[i-1];
}
}
cout<<vec[n-1]<<endl;
}
}

0 comments on commit a5ae4c7

Please sign in to comment.