





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
You have three stacks of cylinders where each cylinder has the same diameter, but they may vary in height. You can change the height of a stack by removing and discarding its topmost cylinder any number of times. Find the maximum possible height of the stacks such that all of the stacks are exactly the same height. This means you must remove zero or more cylinders from the top of zero or more of the three stacks until they are all the same height, then return the height.
Typology: Lab Reports
1 / 9
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):