leetcode1700
Posted 智人心
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode1700相关的知识,希望对你有一定的参考价值。
静态链表
class Solution public: int countStudents(vector<int>& students, vector<int>& sandwiches) int stup = 0,sanp = 0,tmp; int n = students.size(),cnt = 0,n2 = n,tail = n-1; int a[105]; bool flag = false; for(int i=0;i<n;i++) a[i] = i+1; a[n-1] = -1; while(true) if(students[stup]==sandwiches[sanp]) stup=a[stup]; sanp++; cnt = 0; n2--; if(n2==0)break; else cnt++; if(cnt==n2) break; tmp = a[stup]; a[tail] = stup; a[stup] = -1; tail = stup; stup = tmp; return n2; ;
以上是关于leetcode1700的主要内容,如果未能解决你的问题,请参考以下文章