Пікірлер
@andrewmagdy5470
@andrewmagdy5470 2 ай бұрын
Thank you This was good explanation
@frustrated_stuti
@frustrated_stuti 2 ай бұрын
thanks I finally understand
@catskytw
@catskytw 2 ай бұрын
f[0] is 1 which means there is only one way to build fp[0]: "no block". Thus you can just manually caculate f[0]~f[3] and f[4]=f[0]+f[1]+f[2]+f[3]=8
@user-yu6eq7pl2u
@user-yu6eq7pl2u 3 ай бұрын
helper直接//2就好了 谢谢 代码很清楚
@juanghpx
@juanghpx 4 ай бұрын
Great explanation, helped me understand this difficult problem. Thanks for the effort you put into this video.
@MartinSteinausErding
@MartinSteinausErding 5 ай бұрын
Finally someone who describes the algorithm behind the solution. This is very well done.
@shivamshrey47
@shivamshrey47 5 ай бұрын
python3 class Solution: def visibleMountains(self, peaks: List[List[int]]) -> int: # sort peaks in ascending order of (x - y) x-intercept # and also in descending order of (x + y) x-intercept peaks.sort(key=lambda x: ((x[0] - x[1]), -(x[0] + x[1]))) count = 0 max_end = float('-inf') for i, (x, y) in enumerate(peaks): if x + y > max_end: max_end = x + y if i < len(peaks) - 1 and peaks[i] == peaks[i + 1]: continue count += 1 return count
@josh-997
@josh-997 6 ай бұрын
感谢分享,很清晰易懂的解释!
@EstherLi-0509
@EstherLi-0509 6 ай бұрын
Lulu did you come up with this solution independently? Such a genius
@CodeCode-pz6oo
@CodeCode-pz6oo 6 ай бұрын
No, I did reference to the official solution in Hackerrank. Yet, still needs lots of effort from my side to really understand the solution.
@xavierk99
@xavierk99 7 ай бұрын
Hey Lulu, thanks for the explain. I didnt get why we are recursing the *width - the width* of each blocks in minute 7:36
@t0ny360
@t0ny360 7 ай бұрын
In the first step when calculating the number of ways you can build a single wall layer of length 6, why do we add the four previous ones? I don't understnad that part
@xialei3219
@xialei3219 7 ай бұрын
Awesome solution and eloborated explanation, thanks for clarifying this problem!
@juanc94128
@juanc94128 7 ай бұрын
Thank you very much, I was stucked
@nguyenngoctuan7149
@nguyenngoctuan7149 7 ай бұрын
many thanks for your video
@dongyoonkim1211
@dongyoonkim1211 7 ай бұрын
Thank you so much for this explanation. It really helped.
@Po-YuJuan
@Po-YuJuan 7 ай бұрын
Very gorgeous and lucid! Thanks for saving time!
@rubikswiz
@rubikswiz 8 ай бұрын
Awesome explanation Lulu!
@CodeCode-pz6oo
@CodeCode-pz6oo 8 ай бұрын
Thank you! 😃
@slava_xd
@slava_xd 8 ай бұрын
im confused about this "counter" variable. at 6:48 the median is 4 not 3.
@CodeCode-pz6oo
@CodeCode-pz6oo 8 ай бұрын
In the first 5 elements, the sorted window is = [2, 2, 3, 3, 4], so the median is the 3rd element (num3). And for the counter, the counter is the sum of frequency (cdf) up to the median number. For example, there are 2 of 2, 2 of 3, 1 of 4, so the sum of frequency up to 3rd element (cdf) is 2 + 2 = 4, and the median number is 3.
@HaroonRashid72
@HaroonRashid72 8 ай бұрын
Thank you. May you be blessed. I wanted logical help and it was the best resource. Rest of the internet had code.
@CodeCode-pz6oo
@CodeCode-pz6oo 8 ай бұрын
Glad it helped!
@jaylenzhang4198
@jaylenzhang4198 8 ай бұрын
好欢乐,还有bgm
@sezerozer382
@sezerozer382 8 ай бұрын
good
@CodeCode-pz6oo
@CodeCode-pz6oo 8 ай бұрын
Thanks
@TarasSlipets
@TarasSlipets 8 ай бұрын
Great explanation: well-structured, concise, with a practical walkthrough. Many thanks!
@CodeCode-pz6oo
@CodeCode-pz6oo 8 ай бұрын
You're very welcome!
@ethans2536
@ethans2536 9 ай бұрын
omg you actually taught me😂, thanks a lot
@CodeCode-pz6oo
@CodeCode-pz6oo 8 ай бұрын
Happy to help!
@pandukasenevirathna9593
@pandukasenevirathna9593 9 ай бұрын
great explanation. Thanks a lot. This is a harder question.
@himanshukrdiwedi4554
@himanshukrdiwedi4554 9 ай бұрын
Nice
@CodeCode-pz6oo
@CodeCode-pz6oo 9 ай бұрын
Thanks
@Doggy_Styles_Coding
@Doggy_Styles_Coding 10 ай бұрын
nice coding keep it up ,)
@CodeCode-pz6oo
@CodeCode-pz6oo 10 ай бұрын
Thanks!
@letticonionepic
@letticonionepic 10 ай бұрын
To those who are wondering: We counted (1, 3) combo as 4 but (3, 1) as 1 cuz if we break 3 in (3, 1) it will break into (1, 2, 1) and (2, 1, 1) which can already be covered by previous considerations from (2, 2) and (1, 3) so to avoid overlapping it has been done so.
@rayaqin
@rayaqin 7 ай бұрын
Imo your comment is misleading from the pattern of thought in the video. When making 4, it is true that: 2,2 breaks to 112, 211, 1111 (which would be 4 possibilites) and 3,1 breaks to 211, 121, 1111 (which would also be 4 possibilities) but in the explanation she didn't go through all the possible breaks, since she said we keep the first block in tact, and only look for possibilites with the rest of the blocks. You can see she marks the part that needs to be broken down with small diagonal lines. if the first block is a 1, we have 3, 21, 21 and 111, which is 4 possibilities if the first block is a 3, we only have 1 option left for the second block: 1. Thats why it is only 1 there.
@YosvanyBlanco
@YosvanyBlanco 10 ай бұрын
You did a great job explaining the intuition on this one thank you!
@CodeCode-pz6oo
@CodeCode-pz6oo 10 ай бұрын
Glad you enjoyed it!
@sanjanar9198
@sanjanar9198 10 ай бұрын
Great explanation! thank you so much!!
@CodeCode-pz6oo
@CodeCode-pz6oo 10 ай бұрын
Glad you enjoyed it!
@leelashreerajendran8726
@leelashreerajendran8726 11 ай бұрын
Brute force solution : #assume the widest base and tallest mountain max_x = input[0][0] max_y = input[0][1] #calculate the widest base and tallest mountain for i in input: left_base = i[0]-i[1] right_base = i[0]+i[1] max_x = max(max_x, left_base) max_y = max(max_y, i[1]) #generate a 2D map of the scenery scenery = [[0 for i in range(max_y+1)] for j in range(-1*max_x, max_x + 1)] #populate the overlapping mountains for i in input: scenery[i[0]][i[1]] += 1 temp_y = i[1] - 1 counter = 1 while (temp_y > 0): for j in range(counter): scenery[i[0]-j][temp_y] += 1 scenery[i[0]+j][temp_y] += 1 counter += 1 temp_y -= 1 #Find the peaks which are not overlapped visible_mountain = 0 for i in input: if scenery[i[0]][i[1]] == 1: visible_mountain += 1 print(visible_mountain)
@astroswell
@astroswell 11 ай бұрын
Thanks for the solution, Lulu! Could you please explain why is the total of ways to have a split in the wall is a multiplication of number of ways to build left-i and right-i?
@CodeCode-pz6oo
@CodeCode-pz6oo 11 ай бұрын
You can draw on a paper with hight = 1 and width of 4. When the i == 2, left side has 2 ways and right side also 2 ways, so the total is 2 *2.
@macolulu
@macolulu 11 ай бұрын
Hi, Lulu. Greetings from Lulu.
@CodeCode-pz6oo
@CodeCode-pz6oo 11 ай бұрын
Hello!
@trlabhishekh3472
@trlabhishekh3472 11 ай бұрын
The explanation was quite good, but it could have been even better with the code
@CodeCode-pz6oo
@CodeCode-pz6oo 11 ай бұрын
Thanks for the suggestion. Since so many people asking for the coding part, I'll upload a new video for coding recently.
@debochando
@debochando Жыл бұрын
I am trying to solve this problem right now. Your video came in the right moment. Thank you so much.
@CodeCode-pz6oo
@CodeCode-pz6oo Жыл бұрын
Glad it helped
@ANURAGSINGH-nl2ll
@ANURAGSINGH-nl2ll Жыл бұрын
well explained thanks
@ybybyb8bo592
@ybybyb8bo592 Жыл бұрын
28:11 total = 0,1,8,32(should be 64)
@CodeCode-pz6oo
@CodeCode-pz6oo Жыл бұрын
Thanks for the correction.
@saurabhsingh6325
@saurabhsingh6325 Жыл бұрын
Thanks for your nice explanation! <3
@CodeCode-pz6oo
@CodeCode-pz6oo Жыл бұрын
My pleasure!
@rahulsawant2093
@rahulsawant2093 Жыл бұрын
Great Explanation, Thanks Keep it Up
@CodeCode-pz6oo
@CodeCode-pz6oo Жыл бұрын
Thanks for liking
@DEEPAKKUMAR-xe2vb
@DEEPAKKUMAR-xe2vb Жыл бұрын
Explanation was good but it would be more helpful if you explain the code too, Btw keep up the good work. 🙌🙌
@CodeCode-pz6oo
@CodeCode-pz6oo Жыл бұрын
Ok next time
@_SAUBHAGYASINGH-yv1hp
@_SAUBHAGYASINGH-yv1hp Жыл бұрын
if this is ur original voice then let me say your voice is very cute
@CodeCode-pz6oo
@CodeCode-pz6oo Жыл бұрын
Thanks.
@shashankshekhar8186
@shashankshekhar8186 Жыл бұрын
simping ho rhi bahut bhyankar
@arghyadas2836
@arghyadas2836 Жыл бұрын
@@shashankshekhar8186 🤣🤣🤣🤣
@sauravgupta7415
@sauravgupta7415 11 ай бұрын
bro ...hahahaha@@shashankshekhar8186
@noppa2576
@noppa2576 Жыл бұрын
Thanks
@CodeCode-pz6oo
@CodeCode-pz6oo Жыл бұрын
Thanks!
@berserk.4121
@berserk.4121 Жыл бұрын
Continue making videos 👍
@CodeCode-pz6oo
@CodeCode-pz6oo Жыл бұрын
Thanks!