1#include<bits/stdc++.h>
2using namespace std;
3
4int main()
5{
6int a,b;
7a = 1;
8b = 1;
9while(b < n)
10{
11 a += 1;
12 b += a;
13 cout<<"Hi";
14}
15}
1func eatChips(int bowlOfChips) {
2Println("Have some chips!")
3for chips := 0; chips <= bowlOfChips; chips++ {
4// dip chips
5}
6Println("No more chips.")
7}
8func pizzaDelivery(int boxesDelivered) {
9Println("Pizza is here!")
10for pizzaBox := 0; pizzaBox <= boxesDelivered; pizzaBox++ {
11// open box
12[1]
13[2]
14[2]
15[2]
16United International University (UIU)
17Dept. of Computer Science & Engineering (CSE)
18Mid Exam Year: 2021 Trimester: Summer
19Course: CSE 2217/CSI 227 Data Structure and Algorithms II,
20Total Marks: 20, Time: 1 hour, Upload & Download: 15 min
212
22for pizza := 0; pizza <= pizzaBox; pizza++ {
23// slice pizza
24for slice := 0; slice <= pizza; slice++ {
25// eat slice of pizza
26}
27}
28}
29Println("Pizza is gone.")
30}
1class Solution {
2public:
3 int minStoneSum(vector<int>& piles, int k) {
4 int sum=accumulate(piles.begin(), piles.end(), 0);
5 while(k!=0){
6 int i=*max_element(piles.begin(),piles.end());
7 std::vector<int>::iterator it = std::find(piles.begin(), piles.end(), i);
8 int index = std::distance(piles.begin(), it);
9 int t=floor(piles[index]/2);
10 piles[index]=i-t;
11 sum=sum-t;
12 k--;
13 }
14
15 return sum;
16 }
17
18};