aboutsummaryrefslogtreecommitdiff
path: root/russian_doll_envelopes.cpp
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-01-09 22:29:19 +0100
committerJack Sangdahl <[email protected]>2025-01-09 22:29:19 +0100
commit8050c7264ba4487a1e64b150633961097382ac5b (patch)
tree940e0429a5caf113d28a171b2365e79df0af5af4 /russian_doll_envelopes.cpp
parent2d159f42638f87dfca97a0ab50099b0eef651e5e (diff)
downloadleetcode-8050c7264ba4487a1e64b150633961097382ac5b.tar.gz
leetcode-8050c7264ba4487a1e64b150633961097382ac5b.zip
354. russian doll envelopes
Diffstat (limited to 'russian_doll_envelopes.cpp')
-rw-r--r--russian_doll_envelopes.cpp28
1 files changed, 0 insertions, 28 deletions
diff --git a/russian_doll_envelopes.cpp b/russian_doll_envelopes.cpp
deleted file mode 100644
index fce0aa3..0000000
--- a/russian_doll_envelopes.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "leetcode.h"
-
-class Solution {
-public:
- int maxEnvelopes(vector<vector<int>> &envelopes) {
- int n = envelopes.size();
- sort(envelopes.begin(), envelopes.end(), compare);
- vector<int> ans;
- for (int i = 0; i < envelopes.size(); i++) {
- int candidate = envelopes[i][1];
- int idx = lower_bound(ans.begin(), ans.end(), candidate) - ans.begin();
- if (idx >= ans.size())
- ans.push_back(candidate);
- else
- ans[idx] = candidate;
- }
- return ans.size();
- }
-
-private:
- static bool compare(vector<int> &a, vector<int> &b) {
- if (a[0] == b[0])
- return a[1] > b[1];
- return a[0] < b[0];
- }
-};
-
-int main() {}