Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- class Solution
- {
- private:
- const int NMAX = 15005;
- public:
- inline bool find132pattern(vector <int>& nums)
- {
- int minVal[NMAX] = {};
- minVal[0] = nums.front();
- for (int i = 1; i < (int)nums.size(); i++)
- minVal[i] = min(minVal[i - 1], nums[i]);
- for (int j = 1; j < (int)nums.size() - 1; j++)
- for (int k = j + 1; k < (int)nums.size(); k++)
- if (minVal[j - 1] < nums[k] && nums[k] < nums[j])
- return true;
- return false;
- }
- };
- int main()
- {
- vector <int> v{1,3,4};
- Solution *sol = new Solution();
- cout << sol -> find132pattern(v);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement