Leetcode-5008 Fixed Point(不动点)
没啥好说的
1 #define _for(i,a,b) for(int i = (a);i < b;i ++) 2 class Solution 3 { 4 public: 5 int fixedPoint(vector<int>& A) 6 { 7 _for(i,0,A.size()) 8 if(i==A[i]) 9 return i; 10 return -1; 11 } 12 };
没啥好说的
1 #define _for(i,a,b) for(int i = (a);i < b;i ++) 2 class Solution 3 { 4 public: 5 int fixedPoint(vector<int>& A) 6 { 7 _for(i,0,A.size()) 8 if(i==A[i]) 9 return i; 10 return -1; 11 } 12 };