File tree Expand file tree Collapse file tree 1 file changed +70
-0
lines changed
LeetCode/CheckIfArrayIsSortedAndRotated Expand file tree Collapse file tree 1 file changed +70
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < bits/stdc++.h>
2+ #include < gtest/gtest.h>
3+
4+ using namespace std ;
5+
6+
7+
8+ class Solution {
9+ private:
10+ enum status {
11+ front,
12+ end,
13+ };
14+
15+
16+ public:
17+ bool check (vector<int >& nums) {
18+ if (nums.empty ()) return true ;
19+ status s = front;
20+ int last = nums[0 ];
21+ int index = 0 ;
22+ for (int i = 1 ;i < nums.size ();i++){
23+ int n = nums[i];
24+ if (s == front){
25+ if (n < last){
26+ s = end;
27+ index = i;
28+ }
29+ }else {
30+ if (n < last){
31+ return false ;
32+ }
33+ }
34+ last = n;
35+ }
36+ int len = nums.size ();
37+ if (s == front){
38+ return true ;
39+ }
40+ return nums[len-1 ] <= nums[0 ];
41+ }
42+ };
43+
44+
45+ struct T {
46+
47+ };
48+
49+ TEST (Solution,test){
50+ T ts[] = {
51+ {
52+
53+ },
54+
55+ };
56+
57+
58+ for (T t : ts){
59+ Solution solution;
60+
61+ }
62+ }
63+
64+ int main () {
65+ testing::InitGoogleTest ();
66+
67+ return RUN_ALL_TESTS ();
68+ }
69+
70+
You can’t perform that action at this time.
0 commit comments