How to find lower bound of a ? suppose input is cat

#include
#include
using namespace std;
int main() {
char s[10];
cin>>s;
int n=strlen(s);
auto lb=lower_bound(s,s+n,‘a’);
cout<<lb-s;
return 0;
}

@Prabhleen_sheenu lower_bound function accepts a sorted container only because it uses binary search internally, so make sure you sort the container beforehand. https://ide.codingblocks.com/s/257349 you can refer to this code to find the lower_bound of a character in a string.

1 Like

thank you ma’am :slight_smile: :slight_smile:

@Prabhleen_sheenu please mark the doubt as resolved if you dont have any further doubts :slight_smile: