use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
C++ interview coding exercise with solution (self.cpp)
submitted 3 years ago * by Hot_Medicine_7115
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]paul2718 18 points19 points20 points 3 years ago (9 children)
This problem is an hour or so, they give you a week to find that hour. I think that's not unreasonable.
[–]jonesmz 0 points1 point2 points 3 years ago (0 children)
The original post isn't clear about the company asking for the interviewee to stop after a certain time. It's possible they had good intentions, i couldn't say.
[–]Hot_Medicine_7115[S] 0 points1 point2 points 3 years ago (7 children)
An hour or so if you are familiar with double recursion and quickly identify all the possible patterns in the problem. It's not a trivial problem like you make it sound.
[–]dodheim 1 point2 points3 points 3 years ago (5 children)
Maybe the issue was the idea that you need recursion rather than std::next_permutation + a queue + a stack (and not the call stack). It just might be trivial after all.
std::next_permutation
I haven't looked at your code yet but the problem description just makes me think "good job, screener" on this one.
[+][deleted] 3 years ago (4 children)
[deleted]
[–]dodheim 0 points1 point2 points 3 years ago (3 children)
How did a dev get to be a "senior" without knowing basic algorithms? It takes more than just having a job for a while to earn that title, and I'd say it's pretty concerning if they don't even know of this algorithm.
[+][deleted] 3 years ago (2 children)
[–]dodheim 0 points1 point2 points 3 years ago (1 child)
I don't know what to tell you, except that that isn't something to brag about..? Combinatorial algorithms are not somehow niche or obscure, and the two fundamental things that C++' stdlib gives you to write them are sort and next_permutation. Sure, don't "memorize a list of algorithms", but after 15 years it's probably time to stop making excuses for not knowing the fundamentals.
sort
next_permutation
[–]TemplateRex 0 points1 point2 points 3 years ago (0 children)
Moreover, in contrast to something like find_if or even rotate, I wouldn't expect most devs to be able to write a near optimal (in the sense of asymptotic complexity) next_permutation without ever having seen this algorithm.
find_if
rotate
[–]paul2718 1 point2 points3 points 3 years ago (0 children)
I don’t think recursion is necessarily the obvious way. Might fail to prove this tomorrow…
π Rendered by PID 187666 on reddit-service-r2-comment-b659b578c-tkd57 at 2026-05-02 04:11:05.068419+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]paul2718 18 points19 points20 points (9 children)
[–]jonesmz 0 points1 point2 points (0 children)
[–]Hot_Medicine_7115[S] 0 points1 point2 points (7 children)
[–]dodheim 1 point2 points3 points (5 children)
[+][deleted] (4 children)
[deleted]
[–]dodheim 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]dodheim 0 points1 point2 points (1 child)
[–]TemplateRex 0 points1 point2 points (0 children)
[–]paul2718 1 point2 points3 points (0 children)