Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
#include
#include
using namespace std;
int countOccurrences(string str, char ch) {
int count = 0;
for (char c : str) {
if (c == ch) {
count++;
}
}
return count;
}
why you guyes dont use using namespace std ;
you removed "const" is this legal?
you can set range in regex like this:
std::regex("[1-4]")
This comment is hidden because it contains spoiler information about the solution
simple as that... nice one
clever, very clever solution. congrats.
Just a slight difference in syntax, the algorithm is the same.
what does line 12
for (auto x : arr)
do?Edit: Just found the answer here , never heard of range-based loops before;
Oh, thank you kind stranger
Here rbegin() start from last it also called reverse beginning . Same for rend() also . Generally sort function return ascending order sort then descending is just reverse of it .
Thanks
What does .rbegin()/.rend() mean?
Thank you for the hint and link, I saw this kind of pattern a couple of times and didn't know what it was up till now, Danke.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Loading more items...