The Skyline Problem || Leetcode

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ม.ค. 2025

ความคิดเห็น • 33

  • @meme_engineering4521
    @meme_engineering4521 3 ปีที่แล้ว +28

    subhesh sir, please jitna ho sake aap videos bna diya karo, aap ek baar explain kar dete ho toh 2 min mein code ho jaata hai, your explanation literally has magic, liked from 2 accounts

  • @nisargkapadia8548
    @nisargkapadia8548 2 ปีที่แล้ว +8

    For C++ user :
    If you are using priorityQueue in c++ stl u will not be able to solve this problem because there is no remove method in c++ stl priority quque so try to use multiset (not set because in edge test case some buildings start and point are same so make sure to use multiset) so for top element use *object_name.rbegin() and for remove element use find method to find element which u want to delete and after that use erase method thats it you solved problem.

    • @shvmsh20
      @shvmsh20 2 ปีที่แล้ว

      Noted

    • @siddharthsingh420
      @siddharthsingh420 ปีที่แล้ว +1

      CPP Code:
      ```
      vector getSkyline(vector& buildings) {
      vector res;
      multiset pq{0};
      vector points; // {start, -height} {end, height}
      for(auto b : buildings) {
      points.push_back({b[0],-b[2]});
      points.push_back({b[1],b[2]});
      }
      sort(points.begin(),points.end());
      int curHeight = 0;
      for(int i=0;i

  • @deepankerchaudhary7187
    @deepankerchaudhary7187 2 ปีที่แล้ว +1

    You earned a subscriber because of this explanation

  • @arpanbanejee5143
    @arpanbanejee5143 3 ปีที่แล้ว +4

    Great explanation, covering all the edge cases! Thanks a lot!

    • @Pepcoding
      @Pepcoding  3 ปีที่แล้ว +1

      Glad it was helpful! To watch more videos like this visit nados.pepcoding.com

  • @piyushlohiya1977
    @piyushlohiya1977 2 ปีที่แล้ว

    great explanation and that trick of using - for starting height

  • @utsavgupta746
    @utsavgupta746 2 ปีที่แล้ว

    Superb explanation 🙌🙌

  • @pratyushprateek2934
    @pratyushprateek2934 2 ปีที่แล้ว

    Amazing explanation ! Thank you !

  • @vineetgarg9125
    @vineetgarg9125 3 ปีที่แล้ว

    This is awesome explanation. Keep it up.

  • @RithikAgarwal-e9b
    @RithikAgarwal-e9b ปีที่แล้ว

    Awsome!!!

  • @naman1062
    @naman1062 2 ปีที่แล้ว

    If start point of two rectangles is common, then sorting height in ascending order will not work I guess. Please correct me if I am wrong.
    For example: {2,-6}, {2,-8}, {4, 6}, {7, 8}.
    Now as heights are in ascending order, skyline would be: [2,6], [2,8], [7,0], right? or am I missing something.

    • @priyadharshanreddyseelam5476
      @priyadharshanreddyseelam5476 2 ปีที่แล้ว

      watch from 20:17

    • @akashkumarsingh5355
      @akashkumarsingh5355 2 ปีที่แล้ว

      u will have negative heights for start so the one with larger numeric value ie 8 will actually become -8 and so -8 < -6 hence u will get 8 height first

    • @namanjain1474
      @namanjain1474 2 ปีที่แล้ว

      Thanks, got it

  • @jagdish_pawar
    @jagdish_pawar 2 ปีที่แล้ว

    this solution is O(N^2) right? but the better approach is in O(NlogN)

  • @LegitGamer2345
    @LegitGamer2345 3 ปีที่แล้ว +1

    Awesome explanation sir

  • @ankitdebnath2597
    @ankitdebnath2597 3 ปีที่แล้ว

    What an explanation.Woaah👍

    • @Pepcoding
      @Pepcoding  3 ปีที่แล้ว

      Glad you liked it.
      For better experience and well organised content sign up on nados.io
      And for being updated follow us on Instagram instagram.com/pepcoding/

  • @dhruvsinghal6451
    @dhruvsinghal6451 3 ปีที่แล้ว +1

    Wonderful explaination

    • @Pepcoding
      @Pepcoding  3 ปีที่แล้ว

      Glad you liked it.
      Keep learning.
      And for better experience and well organised content visit nados.pepcoding.com

  • @OrewaAkashi
    @OrewaAkashi 2 ปีที่แล้ว

    Very good explanation bro 🔥

  • @mickyman753
    @mickyman753 3 ปีที่แล้ว

    jordaar solution

  • @girikgarg8
    @girikgarg8 2 ปีที่แล้ว

    Done!

  • @utkarshsharma1185
    @utkarshsharma1185 2 ปีที่แล้ว

    Thanks a lot sir

  • @rahulaggarwal3977
    @rahulaggarwal3977 ปีที่แล้ว

    Nice

  • @riyakushwaha4347
    @riyakushwaha4347 3 ปีที่แล้ว

    Wonderful explanation sir

    • @Pepcoding
      @Pepcoding  3 ปีที่แล้ว

      Glad it helped.
      For better experience, visit nados.io, where you will get well curated content and career opportunities.

  • @raghavsinghhal5564
    @raghavsinghhal5564 2 ปีที่แล้ว +1

    how to think first time ???

    • @anujpatel307
      @anujpatel307 2 ปีที่แล้ว

      Impossible for first time unless you have seen such question before!

  • @sohaibmansuri279
    @sohaibmansuri279 2 ปีที่แล้ว

    upload code in c++ also

  • @araragikoyomi7186
    @araragikoyomi7186 3 ปีที่แล้ว

    This was a tough one