Examness

Intermediate C++

2 exercises · in teaching order

  1. 1Sort and de-duplicateWrite `vector<int> unique_sorted(vector<int> v)` returning the values sorted ascending with duplicates removed.sortuniqueerase idiom10m
  2. 2Most frequent word lengthWrite `int commonest_length(const string& text)` returning the word length that occurs most often, splitting on whitespace. On a tie, return the *smaller* length. Empty text returns 0.mapstringstreamcounting12m