Knowee
Questions
Features
Study Tools

int furthestBuilding(vector<int>& heights, int bricks, int ladders) { int n=heights.size(); int count=0; for(int i=0;i<n-1;i++){ if(heights[i]<heights[i+1]){ int diff=heights[i+1]-heights[i]; if(bricks>diff){ count++;… return count; }};

Question

int furthestBuilding(vector<int>& heights, int bricks, int ladders) { int n=heights.size(); int count=0; for(int i=0;i<n-1;i++){ if(heights[i]<heights[i+1]){ int diff=heights[i+1]-heights[i]; if(bricks>diff){ count++;… return count; }};

🧐 Not the exact question you are looking for?Go ask a question

Solution

It seems like you've posted a piece of code and want an explanation for it. However, the code is incomplete and it's hard to understand what you're asking for. Could you please provide the complete code or clarify your question?

Similar Questions

int furthestBuilding(vector<int>& heights, int bricks, int ladders) { int n=heights.size(); int count=0; for(int i=0;i<n-1;i++){ if(heights[i]<heights[i+1]){ int diff=heights[i+1]-heights[i]; if(bricks>diff){ count++;… return count; }};

how Sometimes, a component of a vector can be larger than the magnitude of the vector.

long long largestPerimeter(vector<int>& nums) { int n=nums.size(); if (n<3) return -1; sort(nums.begin(),nums.end()); int sum=nums[0]+nums[1]+nums[2]; int perimeter=0,i=3,newsum;… } return perimeter; }

According to counting sort, which line is not correct?void solve(){ int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int maxi = *max_element(a.begin(), a.end()); int mini = *min_element(a.begin(), a.end()); vector<int> f(maxi - mini + 2);//Statement A for (int i = 0; i < n; i++) { f[(a[i] - mini)++];//Statement B } for (int i = 0; i < f.size(); i++) { for (int j = 0; j < f[i]; j++) { cout << (i + mini) << " ";// Statement C } }}

A vector has a magnitude of 2m, but is pointing in an unknown direction. What is the maximum possible magnitude of its horizontal component?

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.