No video

Ugly Number - Leetcode 263 - Python

  Рет қаралды 25,082

NeetCode

NeetCode

Күн бұрын

Пікірлер: 30
@youngee9403
@youngee9403 2 жыл бұрын
there are times that i wonder if im being punished for skipping all my math classes during undergrad
@NeetCode
@NeetCode 2 жыл бұрын
I feel the same sometimes lol
@user-us7rg4cd6p
@user-us7rg4cd6p 3 ай бұрын
There are times I wonder if I am being punished for not studying Computer Science Major but trying to be a software programmer.. lol
@jideabdqudus
@jideabdqudus 3 жыл бұрын
My Favorite YT chanel, don't ask me why
@ambujhakhu7531
@ambujhakhu7531 3 жыл бұрын
why
@playonce4186
@playonce4186 2 жыл бұрын
@@ambujhakhu7531 dont worry why he said
@shavvasatya7131
@shavvasatya7131 Жыл бұрын
But how
@harshaggarwal1967
@harshaggarwal1967 2 жыл бұрын
You just made it quick and easy.. Thanks!!
@NeetCode
@NeetCode 2 жыл бұрын
Glad it helped!
@swatiaga8554
@swatiaga8554 2 жыл бұрын
you can also add one more condition at while loop that n!= 0 otherwise the loop will be infinite.
@sudluee
@sudluee 3 жыл бұрын
i think the worse case time complexity is O(log(2)n) that's if n is only divisible by 2.
@fsteve6443
@fsteve6443 3 жыл бұрын
the GOAT uploaded
@BB8_CA
@BB8_CA 3 жыл бұрын
As aways!
@littlecatboybuddy
@littlecatboybuddy Жыл бұрын
I watch entire videos! Because I'm a beginner so the coding section is really helpful! Thank you for the great explanation :)
@duckieace
@duckieace 2 жыл бұрын
What happens if n is 1. This code seems like it return it as True even though the prime number of 1 is not 2 3 or 5. shouldn't it be if n
@spaceface2288
@spaceface2288 2 жыл бұрын
if n == 0: return False while n % 2 == 0: n = n / 2 while n % 3 == 0: n = n / 3 while n % 5 == 0: n = n / 5 return n == 1
@sahanar4805
@sahanar4805 2 жыл бұрын
+1
@harshaggarwal1967
@harshaggarwal1967 2 жыл бұрын
1 has no prime factors, therefore all of its prime factors are limited to 2,3 and 5..so we can take it as ugly number.. Hence return true for this case..
@amalaljohari9358
@amalaljohari9358 Жыл бұрын
Actually that shows "Time Limit Exceeded" A better solution can be: if (n < 0) return false; while (n > 1) { if (n % 2 == 0) n /= 2; else if (n % 3 == 0) n /= 3; else if (n % 5 == 0) n /= 5; else return false; } return n ==1;
@NegiRohit
@NegiRohit Жыл бұрын
I came up with this exact solution without seeing this code.
@Gerald-iz7mv
@Gerald-iz7mv Жыл бұрын
hi - is there a leetcode playlist for this as well?
@maamounhajnajeeb209
@maamounhajnajeeb209 Жыл бұрын
Thanks
@_tan2112
@_tan2112 Жыл бұрын
Helpfull
@Rishabhsingh-ev7ii
@Rishabhsingh-ev7ii 2 жыл бұрын
i think u r from mars ur every video is educative
@monkeyDluffy-sd3zp
@monkeyDluffy-sd3zp Жыл бұрын
20 is not considered an ugly number. An ugly number must only be divisible by 2, 3, or 5, but 20 is also divisible by 4, which is not among the allowed prime factors. -source chatgpt
@user-qg7lb1jx8b
@user-qg7lb1jx8b Жыл бұрын
4 is not prime
@ChrisCox-wv7oo
@ChrisCox-wv7oo 11 ай бұрын
Being divisible by 4 is the same as being divisible by 2 two times... I'm not sure if Chad GPT is going to do mentally cripple an entire generation of engineers, or help them learn quicker through failure
@monkeyDluffy-sd3zp
@monkeyDluffy-sd3zp Жыл бұрын
but the test case says 20 is an ugly number.
@gersonsales9231
@gersonsales9231 2 жыл бұрын
++subscribers
Ugly Number II - Leetcode 264 - Python
15:17
NeetCodeIO
Рет қаралды 13 М.
Leetcode 264. Ugly Number II
18:11
Code with Alisha
Рет қаралды 16 М.
王子原来是假正经#艾莎
00:39
在逃的公主
Рет қаралды 25 МЛН
女孩妒忌小丑女? #小丑#shorts
00:34
好人小丑
Рет қаралды 98 МЛН
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 302 М.
Furthest Building You Can Reach - Leetcode 1642 - Python
11:08
NeetCodeIO
Рет қаралды 15 М.
Word Break - Dynamic Programming - Leetcode 139 - Python
15:35
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
王子原来是假正经#艾莎
00:39
在逃的公主
Рет қаралды 25 МЛН