首页 > 其他分享 >Leetcode457

Leetcode457

时间:2023-01-03 00:00:37浏览次数:39  
标签:Leetcode457 curr nums int next start size

A very absurd description for this problem, but people can get the idea by looking at the examples....

 

 

bool circularArrayLoop(vector<int>& nums) {      int n = nums.size();   int curr = 0, next = 0;  // 2 points     for (int start = 0, size_cnt = 0; start < n; ){      //syntax    curr = next;   next = (curr +(nums[curr] %n )+n )%n;   if (++size_cnt >n || nums[curr] * nums[next] < 0 || next == curr){     next = ++start;     size_cnt =0;             }   else if (next == start){return true;} } return false; }   Also more advanced solution can apply~

标签:Leetcode457,curr,nums,int,next,start,size
From: https://www.cnblogs.com/selfmade-Henderson/p/17020886.html

相关文章