Skip to content

Instantly share code, notes, and snippets.

@AmosAidoo
Created December 18, 2019 09:53
Show Gist options
  • Save AmosAidoo/4c1fbdf7ec5dd916ef854dad219e212b to your computer and use it in GitHub Desktop.
Save AmosAidoo/4c1fbdf7ec5dd916ef854dad219e212b to your computer and use it in GitHub Desktop.
void _empty(int* Sk, int& T, int n) {
int groupCount = 0;
do {
//m will be the top-most item on the stack and on subsequent groups
int m = Sk[T];
//Remove all m elements from the stack
T = T - m - 1;
groupCount += 1;
} while (T > 0);
cout << "The number of groups is " << groupCount << "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment