Ugly Number II | Dynamic Programming | Leetcode - 264

preview_player
Показать описание
Detailed explanation for Ugly Number II leetcode dynamic problem 264.

The day 4 problem in July Leetcoding Challenge. ( Ugly Number II ).

Problem statement:
Write a program to find the n-th ugly number.

Ugly numbers are positive numbers whose prime factors only include 2, 3, 5.

Example:

Input: n = 10
Output: 12
Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers.
Note:

1 is typically treated as an ugly number.
n does not exceed 1690.

If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful.

#coding #leetcode #challenges
Рекомендации по теме
Комментарии
Автор

I hope you all are enjoying the July leetcoding challenge!!! Don't forget to leave a comment!!! Please like the video to support us!!!
Struggling in a question??
Leave in a comment and we will make a video!!!🙂🙂🙂

AlgorithmsMadeEasy
Автор

Visual explanation is excellent it's really made easy to understand the problem👍👏

jabedhasan
Автор

Your initialize an arr of size n so Space Complexity is O(N) and you iterate the entire arr the Time Complexity is O(N)

SHAIKLALBASHA-pv
Автор

Time and space complexity is O(N) although max loops we make is 1690. They could pass 1690 as N or could be a number less than that.

Also, in your case it makes 1690 loops every time although N could be much significantly less number. Change 1690 to N to improve time & space complexity.

+1 vote for the unique approach. I loved it.

hemaladani
Автор

Don't just explain the algorithm!!! Why and how did you approach this algorithm is important!!! I am not trying to demoralize you but the intuition is what everybody is looking for

Elon-musk-
Автор

Animated explanation helped me to understand the logic, lucid and clear explanation, thanks!

NoName-iptt
Автор

hey, your videos are amazing but I have a doubt. when checking the conditions I was using if, else if and else if and my answer was wrong.
but you guys have used three ifs.
what is the difference and how does that change the answer.

shashankjha
Автор

hello, which tool do you use to make this amazing vedeos

vamsinadh
join shbcf.ru