Find the earliest time when a frog can jump to the other side of a river.
Solution
#include <set>int solution(int X, vector<int> &A) { // write your code in C++11 (g++ 4.8.2) set<int> s; for (size_t i = 0; i < A.size(); i++) { s.insert(A[i]); if (s.size() == X) return i; } return -1; }