diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/valid_stack_seq.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/valid_stack_seq.cpp')
-rw-r--r-- | other/valid_stack_seq.cpp | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/other/valid_stack_seq.cpp b/other/valid_stack_seq.cpp deleted file mode 100644 index 62250db..0000000 --- a/other/valid_stack_seq.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// 946. Validate Stack Sequences -#include "leetcode.h" - -/* - * given two integer arrays 'pushed' & 'popped' each with distinct - * values, return true if this could have been the result of a sequence - * of push and pop operations on an initially empty stack, or false otherwise - */ - -class Solution { -public: - bool validateStackSequences(vector<int> &pushed, vector<int> &popped) { - stack<int> s; - int i = 0; - for (int x : pushed) { - s.push(x); - while (s.size() && s.top() == popped[i]) { - s.pop(); - i++; - } - } - return !s.size(); - } -}; - -int main() { - Solution obj; - vector<int> pushed = {1, 2, 3, 4, 5}; - vector<int> p1 = {4, 5, 3, 2, 1}, p2 = {4, 3, 5, 1, 2}; - printf("%d\n", obj.validateStackSequences(pushed, p1)); // expect: 1 - printf("%d\n", obj.validateStackSequences(pushed, p2)); // expect: 0 -} |