Skyline Problem

Skyline Problem

198,351 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@jaideeppyne1880
@jaideeppyne1880 - 06.01.2021 12:40

Does this pass for the case where input array is [[0,2,3],[2,5,3]]? Implemented in C++ its not passing

Ответить
@mbuchove
@mbuchove - 29.01.2021 06:27

Consistently excellent explanations!

Ответить
@prajaktakarandikar3459
@prajaktakarandikar3459 - 02.02.2021 08:57

Anytime the height changes, add the x coordinate and the current max height to the answer.

Ответить
@149shayakmalakar7
@149shayakmalakar7 - 05.02.2021 20:54

thanks brother

Ответить
@ranga400
@ranga400 - 13.02.2021 22:02

Just Brilliant. Appreciate your patience in going through the code line by line and using the visual to make things clear. Hats off

Ответить
@snehalbedmutha1895
@snehalbedmutha1895 - 15.02.2021 20:45

Thank you for this excellent explanation. I wrote your code in Python and I'm getting TLE for one test case (69/70 passed).

Ответить
@Kavishkhullar
@Kavishkhullar - 07.03.2021 10:49

saw the compareTo method you wrote. It's a great implementation.

Ответить
@junnunsafoan3977
@junnunsafoan3977 - 04.06.2021 16:33

Tushar is LC Legend.

Ответить
@Atpugtihsrah
@Atpugtihsrah - 08.06.2021 22:12

Can't thank you enough for this great explanation!

Ответить
@123chen9
@123chen9 - 25.06.2021 09:06

I have to say this is the simplest explaination I have ever seen! Thank you

Ответить
@meghna1320
@meghna1320 - 26.06.2021 22:02

Thanks Tushar, this is very helpful!

Ответить
@riturajsarkar6665
@riturajsarkar6665 - 01.07.2021 16:29

can someone suggest what datastructure should be used for c++ code?

Ответить
@yashkute2350
@yashkute2350 - 02.07.2021 19:14

"ssTHHHart"

Ответить
@TheCuriousCurator-Hindi
@TheCuriousCurator-Hindi - 06.07.2021 19:11

Doesn't talk about design of solution. Directly starts with dry run of solution.

Ответить
@ranesh237
@ranesh237 - 11.07.2021 02:56

Is this a line-sweep problem?

Ответить
@SunilPatel-sf5ng
@SunilPatel-sf5ng - 27.07.2021 21:24

Thank you so much sir. I've a got a job because of you. Please continue to deliver awesome algorithms and techniques.

Ответить
@poojaprasanthi1272
@poojaprasanthi1272 - 29.07.2021 05:48

Thanks Tushar

Ответить
@shashankkumar1974
@shashankkumar1974 - 22.08.2021 18:14

Can we use multiset like data structure in C++

Ответить
@rahul38474
@rahul38474 - 19.10.2021 08:58

I got this question in a final round for an internship and even though I barely understood the question I still somehow managed to come up with this solution, I didn’t even understand the answer I was giving the interviewer.

Ответить
@Young10489
@Young10489 - 15.11.2021 06:38

Tushar has become my favorite Indian .

Ответить
@darthvader_
@darthvader_ - 20.11.2021 04:15

Great Explanation

Ответить
@arsalalam5998
@arsalalam5998 - 24.12.2021 00:17

Thank you.

Ответить
@anameira1324
@anameira1324 - 30.12.2021 18:15

Does anyone has this algorithm written in C?

Ответить
@Rachitagupta11
@Rachitagupta11 - 31.12.2021 19:45

how much time did it take for you to solve this?

Ответить
@kathansanghavi5451
@kathansanghavi5451 - 26.01.2022 15:28

Thank you very much !!

Ответить
@1SniperToRuleThemAll
@1SniperToRuleThemAll - 02.03.2022 01:00

i do not understand how the new array is created (with 2 times the points) and then sorted in O(n) time

Ответить
@zhangbrian102
@zhangbrian102 - 19.03.2022 03:17

Cannot thank more. Do appreciate your great explanation!

Ответить
@kukikukac
@kukikukac - 05.09.2022 16:32

This is a terrible problem like you just need to memorize it

Ответить
@chenhaofeng4842
@chenhaofeng4842 - 16.09.2022 17:42

The best video for skyline problem

Ответить
@usrenaem
@usrenaem - 27.09.2022 04:24

When I saw this task for the first time I have absolutely no idea how to solve it, no technics/algorithms I knew including priority queue looked like a possible solution. Thanks a lot for that clear explanation!

Ответить
@herculean6748
@herculean6748 - 01.10.2022 09:08

Great explanation!!

Ответить
@deathbombs
@deathbombs - 09.10.2022 09:41

The sorting algorithm for buildingPoints class is key here for finding start, end, and skyline height:
(this.isStart ? -this.height : this.height - o.isStart ? -o.height : o.height)
if same x, sort the start points by height, ignore the end points
if not same x, sort by x

Ответить
@deathbombs
@deathbombs - 10.10.2022 06:52

If we wanted to use priorityQueue instead of TreeMap, would this help optimize? PQ<BuildingPoint>

Current solution to clarify is:
TreeMap<Integer = height, Integer = occurences>

Ответить
@ahmadbodayr7203
@ahmadbodayr7203 - 08.12.2022 18:50

Great vid Tushar thanks so much. If you are not muslim read about islam Tushar❤

Ответить
@dheerajsharma355
@dheerajsharma355 - 08.02.2023 14:00

bro why cant you pronounce start as start instead of starhht, btw great video

Ответить
@Tejas8272
@Tejas8272 - 18.02.2023 12:49

Finally able to solve with your explanation after almost 2 days searching debugging others solution /code
Thank you👍🏻

Ответить
@joyone6031
@joyone6031 - 15.04.2023 06:29

So good to not like

Ответить
@amritaanshnarain7524
@amritaanshnarain7524 - 06.09.2023 18:21

aap please point ko phoint mat bolo. video nhi dekh paa rha

Ответить
@shrn
@shrn - 19.01.2024 19:46

I've looked at 5-6 tutorials but did not understand what to do, but after watching this video, it became very simple

Ответить
@hannanathar3627
@hannanathar3627 - 02.03.2024 19:25

Java Code using Priority Queue
class Solution {

public List<List<Integer>> getSkyline(int[][] a) {

List<List<Integer>> res=new ArrayList<>();

List<Triplet> list =new ArrayList<>();

for(int i=0;i<a.length;i++)
{
list.add(new Triplet(a[i][0],a[i][2],true));
list.add(new Triplet(a[i][1],a[i][2],false));

}





Collections.sort(list,new Comparator<Triplet>(){

public int compare(Triplet o1,Triplet o2)
{

//first compare by x.
//If they are same then use this logic
//if two starts are compared then higher height building should be picked first
//if two ends are compared then lower height building should be picked first
//if one start and end is compared then start should appear before end

if(o1.x!=o2.x)
return o1.x-o2.x;

else
{
if(o1.start==true && o2.start==true)
return o2.height-o1.height;

else if(o1.start==false && o2.start==false)
return o1.height-o2.height;

else
{
if(o1.start==true)
return -o1.height;
else
return -o2.height;
}
}
}

});




PriorityQueue<Integer> pq=new PriorityQueue<>(Collections.reverseOrder());
pq.add(0);
int prevmax=0;

for(Triplet t:list)
{
if(t.start==true)
{
pq.add(t.height);
}

else
{
pq.remove(t.height);
}

int currmax=pq.peek();

if(currmax!=prevmax)
{
List<Integer> temp=new ArrayList<>();
temp.add(t.x);
temp.add(currmax);
res.add(new ArrayList<>(temp));
prevmax=currmax;
}



}
return res;




}

public static class Triplet
{
int x,height;
boolean start;

Triplet(int xx,int yy,boolean s)
{
x=xx;
height=yy;
start=s;
}
}
}

Ответить
@nirmalgurjar8181
@nirmalgurjar8181 - 19.04.2024 23:52

All 3 edge cases are covered if we mark -ve height for start the building and now if starts are same then height can be matched.

Ответить
@MuhammadIlham-bh9py
@MuhammadIlham-bh9py - 23.05.2024 11:19

👍

Ответить
@VuNguyen-hi3fu
@VuNguyen-hi3fu - 11.06.2024 13:58

does the algorithm stays the same when buildings are extended to n-dimension space

Ответить
@benpurcell591
@benpurcell591 - 16.07.2024 23:56

3 mins in , very clear, great explanation

Ответить
@shambhhavvviii
@shambhhavvviii - 12.03.2025 15:48

Thanks for such a good explanation.

Ответить
@raiyanrazi1144
@raiyanrazi1144 - 02.05.2025 22:56

Never talks about intuition. Just directly jumps to the solution. I don't know how people find this helpful. All his videos are like this. No intuition discussion, just directly jumps to the solution like a mugged up robot.

Ответить
@keshavgoswami9846
@keshavgoswami9846 - 01.06.2025 12:57

change ur channel name to coding made hell

Ответить

Skyline Problem Tushar Roy - Coding Made Simple
Компьютеру все возрасты покорны Бендерское Телевидение
Память афганской войны Центр детского творчества Верхняя Салда