leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2424.cpp (366B)


      1 class LUPrefix {
      2   public:
      3     LUPrefix(int n) : n(n) { memset(seen, 0x00, sizeof(seen)); }
      4 
      5     void upload(int video) { seen[video] = true; }
      6 
      7     int longest() const {
      8         while (seen[next])
      9             next++;
     10         return next - 1;
     11     }
     12 
     13   private:
     14     const int n;
     15     mutable int next = 1;
     16 
     17     static int seen[100001];
     18 };
     19 
     20 int LUPrefix::seen[100001];