We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
//3 static variables height1, height2, height3 are there. //They stores sum of all elements in the vector.//findMax() return 1 if h1 is max, 2 if h2 is max and 3 if h3 is maxintgetMaxEqualHeight(vector<int>h1,vector<int>h2,vector<int>h3){//areEqual() returns 1 if all heights are equal;while(areEqual()!=1){intmax=findMax();if(max==1){height1=height1-h1[0];h1.erase(h1.begin());}elseif(max==2){height2=height2-h2[0];h2.erase(h2.begin());}else{height3=height3-h3[0];h3.erase(h3.begin());}}returnheight1;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Equal Stacks
You are viewing a single comment's thread. Return to all comments →