Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • IoT ? Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone

HackerEarth Unique subsequences problem solution

YASH PAL, 31 July 2024
In this HackerEarth Unique subsequences problem solution You are given a string S that contains N characters. Your task is to determine the maximum possible size of the subsequence T of S such that no two adjacent characters in T are the same.
HackerEarth Unique subsequences problem solution

HackerEarth Unique subsequences problem solution.

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
ll t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
string s;
cin>>s;
ll ans=0;
char last='-';
for(ll i=0;i<n;i++)
{
if(last != s[i])
{
last = s[i];
ans++;
}
}
cout<<ans<<"n";
}
return 0;
}
coding problems solutions

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes