





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Student Name: Diksha Sharma UID: 20BCS Branch: Computer Science Engineering Section/Group: 20BCS_MM-807-A Semester: 5 Date of Performance:23/08/ Subject Name: Competitive Coding Subject Code: 20CSP- Problem 1: https://www.hackerrank.com/challenges/equal-stacks/problem
**1. Aim/Overview of the practical: To demonstrate the concept of Stack and Queue.
4. Code: #include<bits/stdc++.h> using namespace std; int n1, n2, n3; int ok[20000000], a[100010], b[100100], c[100100]; int main() { cin >> n1 >> n2 >> n3; for(int i = 0; i < n1; i++) cin >> a[i]; for(int i = 0; i < n2; i++) cin >> b[i]; for(int i = 0; i < n3; i++) cin >> c[i]; reverse(a, a + n1); reverse(b, b + n2); reverse(c, c + n3); int ret = 0, sum = 0, ai; for(int i = 0; i < n1; i++) { ai = a[i]; sum += ai; ok[sum] = 1; } sum = 0; for(int i = 0; i < n2; i++) { ai = b[i]; sum += ai; if (ok[sum] == 1) ok[sum] = 2; } sum = 0; for(int i = 0; i < n3; i++) { ai = c[i]; sum += ai; if (ok[sum] == 2) ret = sum; } cout << ret << endl; return 0;
Problem 2: https://www.hackerrank.com/challenges/game-of-two-stacks/problem?isFullScreen=true
**1. Aim/Overview of the practical: To demonstrate the concept of Stack and Queue.
Nick's final score is the total number of integers he has removed from the two stacks. Given , , and for games, find the maximum possible score Nick can achieve
3. Algorithm:
Learning outcomes (What I have learnt):