← Back to archive

Stdle #32 · containers · 2026-07-08

What does this C++ snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

#include <iostream>
#include <vector>
#include <algorithm>
int main() {
std::vector<int> v = {4, 2, 5, 1, 3};
std::sort(v.begin(), v.end());
std::cout << v.front() << " " << v.back() << "\n";
}
Containers
4 attempts left

Answer & explanation