class Solution{ public: int isStackPermutation(int N,vector &A,vector &B){ stack st; int i=0,j=0; while(j<N) { while(i<N && (st.empty() || st.top()!=B[j])) { st.push(A[i]); i++; } while(!st.empty() && st.top()==B[j]) { st.pop(); j++; } if(i==N && !st.empty() && st.top()!=B[j]) return 0; } return 1; } };
-
Notifications
You must be signed in to change notification settings - Fork 0
LeenaMondal01/stack
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published