Kodewick
Start learning →
Starter←→0 / 60

Class photo

#047StarterAlgorithms2 min

For the class photo everyone lines up from shortest to tallest. Write photo_line(heights): use sort from <algorithm> to put the heights in order, smallest first, and return them.

Examples
photo_line({150, 138, 145})→[138, 145, 150]
photo_line({})→[]
The functionvector<int> photo_line(vector<int> heights)
main.cpp
#include <algorithm>
#include <vector>
using namespace std;

vector<int> photo_line(vector<int> heights) {
    // your code here: sort heights
    return heights;
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.