198392013 I got wrong while using GNU C++20 as compiler. But the same solution is accepted by GNU C++17 compiler.
198391568 This is the accepted solution using GNU C++17 compiler.
I wasted 5 to 6 hrs in searching of error, but it was the compiler. It's really frustrating while searching for errors, when there's not any.
Are the additional library in GNU C++20 causing this issue? I have used set in this problem, which seems to be not handled properly by this compiler.
Your code contains undefined behavior and you just get very lucky that it works with the c++17 compiler.
When s is empty (or in cases where lower_bound isn't in s) then s.lower_bound returns s.end() and *it is undefined.
I'm not really sure what you are doing here — you've already got an iterator pointing to that value so dereferencing it to call find doesn't do anything. s.find(*it) will always just return it (except for when *it is undefined).
Compiling with -D_GLIBCXX_DEBUG highlights your error as soon as you run the code.
Thanks for the insight.
Please tell how do I compile using that? It is not in the language options in Custom Innvocation.
Add
#define _GLIBCXX_DEBUG
on the top of your code before#include
's.The audacity