//reversal of queue //{ Driver Code Starts //Initial Template for C++ #include using namespace std; queue rev(queue q); int main() { int test; cin>>test; while(test--) { queue q; int n, var; cin>>n; while(n--) { cin>>var; q.push(var); } queue a=rev(q); while(!a.empty()) { cout< rev(queue Q) { // add code here. stacks; while(!Q.empty()){ int element=Q.front(); Q.pop(); s.push(element); } while(!s.empty()){ int element=s.top(); s.pop(); Q.push(element); } return Q; } //First negative integer in every window of size k //{ Driver Code Starts #include using namespace std; vector printFirstNegativeInteger(long long int arr[], long long int n, long long int k); // Driver program to test above functions int main() { long long int t, i; cin >> t; while (t--) { long long int n; cin >> n; long long int arr[n]; for (i = 0; i < n; i++) { cin >> arr[i]; } long long int k; cin >> k; vector ans = printFirstNegativeInteger(arr, n, k); for (auto it : ans) cout << it << " "; cout << endl; } return 0; } // } Driver Code Ends vector printFirstNegativeInteger(long long int A[], long long int N, long long int K) { dequedq; vectorans; //process first window for(int i=0; i0){ ans.push_back(A[dq.front()]); } else{ ans.push_back(0); } //remaining win for(int i=K ; i=K){ dq.pop_front(); } //addition if(A[i]<0){ dq.push_back(i); } //ans store if(dq.size()>0){ ans.push_back(A[dq.front()]); } else{ ans.push_back(0); } } return ans; } //Reverse First K elements of Queue //{ Driver Code Starts // Initial Template for C++ #include using namespace std; queue modifyQueue(queue q, int k); int main() { int t; cin >> t; while (t-- > 0) { int n, k; cin >> n >> k; queue q; while (n-- > 0) { int a; cin >> a; q.push(a); } queue ans = modifyQueue(q, k); while (!ans.empty()) { int a = ans.front(); ans.pop(); cout << a << " "; } cout << endl; } } // } Driver Code Ends // User function Template for C++ // Function to reverse first k elements of a queue. queue modifyQueue(queue q, int k) { // add code here. stacks; for(int i=0; i using namespace std; // } Driver Code Ends class Solution { public: string FirstNonRepeating(string A){ unordered_map count; queue q; string ans = ""; for(int i=0; i 1){ q.pop(); } else { ans.push_back(q.front()); break; } } if(q.empty()){ ans.push_back('#'); } } return ans; } }; //{ Driver Code Starts. int main(){ int tc; cin >> tc; while(tc--){ string A; cin >> A; Solution obj; string ans = obj.FirstNonRepeating(A); cout << ans << "\n"; } return 0; } // } Driver Code Ends //Circular tour //{ Driver Code Starts #include using namespace std; struct petrolPump { int petrol; int distance; }; // } Driver Code Ends /* The structure of petrolPump is struct petrolPump { int petrol; int distance; };*/ /*You are required to complete this method*/ class Solution{ public: //Function to find starting point where the truck can start to get through //the complete circle without exhausting its petrol in between. int tour(petrolPump p[],int n) { //Your code here int deficit=0; int balance=0; int start=0; for(int i=0; i0) return start; else{ return -1; } } }; //{ Driver Code Starts. int main() { int t; cin>>t; while(t--) { int n; cin>>n; petrolPump p[n]; for(int i=0;i>p[i].petrol>>p[i].distance; Solution obj; cout<