๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.61K photos
3 videos
95 files
10.6K links
๐ŸšฉMain Group - @SuperExams
๐Ÿ“Job Updates - @FresherEarth

๐Ÿ”ฐAuthentic Coding Solutions(with Outputs)
โš ๏ธDaily Job Updates
โš ๏ธHackathon Updates & Solutions

Buy ads: https://telega.io/c/cs_algo
Download Telegram
1642. Furthest Building You Can Reach
You are given an integer array heights representing the heights of buildings, some bricks, and some ladders.
You start your journey from building 0 and move to the next building by possibly using bricks or ladders.
While moving from building i to building i+1 (0-indexed),
If the current building's height is greater than or equal to the next building's height, you do not need a ladder or bricks.
If the current building's height is less than the next building's height, you can either use one ladder or (h[i+1] - h[i]) bricks.
Return the furthest building index (0-indexed) you can reach if you use the given ladders and bricks optimally.
Input: heights = [4,12,2,7,3,18,20,3,19], bricks = 10, ladders = 2
Output: 7
*/
class Solution
{
public:
int furthestBuilding(vector<int> &heights, int bricks, int ladders)
{
priority_queue<int> maxB;
int i = 0, diff = 0;
for (i = 0; i < heights.size() - 1; i++)
{
diff = heights[i + 1] - heights[i];
if (diff <= 0)
{
continue;
}
bricks -= diff;
maxB.push(diff);
if (bricks < 0)
{
bricks += maxB.top();
maxB.pop();
ladders--;
}
if (ladders < 0)
break;
}
return i;
}
};

Amazon (leetcode) โœ…
๐Ÿ‘4
Hexaview interview experienceโœ…
1) self intro
2) asked 3 coding questions
1 given array and values x
Check weather pair sum equal to x in o(n)
2) given string
Reverse each word maintaing order in o(n)
Ex i love books
Result i evol skoob
3 ) given arrays O's 1's 2's
Sort array without sorting function in o(n)
One logical question
Given two rod
One rod takes 60 mints to burn totally
Measure time taken for 45 mints
๐Ÿ‘1