2345. Finding the Number of Visible Mountains (Leetcode Medium)

  Рет қаралды 662

Programming Live with Larry

Programming Live with Larry

Күн бұрын

Пікірлер: 3
@Algorithmist
@Algorithmist Жыл бұрын
How many mountains do you see?
@rosendo3219
@rosendo3219 Жыл бұрын
happy birthday Larry!
@leelashreerajendran8726
@leelashreerajendran8726 Жыл бұрын
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)
2015. Average Height of Buildings in Each Segment (Leetcode Medium)
16:51
Programming Live with Larry
Рет қаралды 187
Find the Maximum Sum of Node Values - Leetcode 3068 - Python
17:50
Mom had to stand up for the whole family!❤️😍😁
00:39
What's in the clown's bag? #clown #angel #bunnypolice
00:19
超人夫妇
Рет қаралды 26 МЛН
Synyptas 4 | Арамызда бір сатқын бар ! | 4 Bolim
17:24
New largest prime number found! See all 41,024,320 digits.
10:14
Stand-up Maths
Рет қаралды 320 М.
How is this Website so fast!?
13:39
Wes Bos
Рет қаралды 511 М.
30 Programming Truths I know at 30 that I Wish I Knew at 20
17:41
Coding Challenge 162: Self-Avoiding Walk
38:27
The Coding Train
Рет қаралды 153 М.
How I animate 3Blue1Brown | A Manim demo with Ben Sparks
53:41
3Blue1Brown
Рет қаралды 729 М.
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
LeetCode 2104. Sum of Subarray Ranges
24:37
Kacy Codes
Рет қаралды 10 М.
How I Got Good at Coding Interviews
6:29
NeetCode
Рет қаралды 1,7 МЛН
How I Would Learn To Code (If I Could Start Over)
13:43
Namanh Kapur
Рет қаралды 7 МЛН
Mom had to stand up for the whole family!❤️😍😁
00:39