Twice linear Time : Space : 12345678910111213141516171819202122232425#include <bits/stdc++.h>using namespace std;class DoubleLinear{public: static int dblLinear(int n);};int DoubleLinear::dblLinear(int n) { unordered_set<int> us; priority_queue<int, vector<int>, greater<int>> q; q.push(1); auto insert = [&](int x) { if(!us.count(x)) { us.insert(x); q.push(x); } }; while(n--) { auto u = q.top(); q.pop(); us.erase(u); insert(u * 2 + 1); insert(u * 3 + 1); } return q.top();}