Тёмный

Valid Perfect Square - Leetcode 367 - Binary Search (Python) 

Greg Hogg
Подписаться 150 тыс.
Просмотров 1,3 тыс.
50% 1

The Python code for this problem can be found at my GitHub repo here: github.com/gahogg/Leetcode-So...
Please check my playlists for free DSA problem solutions:
• Arrays, Strings, and H...
• 2 Pointers Questions
• Sliding Window Questions
• Binary Search Questions
• Stack Questions
• Linked List Questions
• Binary Tree & Binary S...
• Heap Questions
• Recursive Backtracking...
• Graph Questions
• Dynamic Programming (D...
Learn Python and Data Science at mlnow.ai :)
Best Courses for Analytics:
---------------------------------------------------------------------------------------------------------
+ IBM Data Science (Python): bit.ly/3Rn00ZA
+ Google Analytics (R): bit.ly/3cPikLQ
+ SQL Basics: bit.ly/3Bd9nFu
Best Courses for Programming:
---------------------------------------------------------------------------------------------------------
+ Data Science in R: bit.ly/3RhvfFp
+ Python for Everybody: bit.ly/3ARQ1Ei
+ Data Structures & Algorithms: bit.ly/3CYR6wR
Best Courses for Machine Learning:
---------------------------------------------------------------------------------------------------------
+ Math Prerequisites: bit.ly/3ASUtTi
+ Machine Learning: bit.ly/3d1QATT
+ Deep Learning: bit.ly/3KPfint
+ ML Ops: bit.ly/3AWRrxE
Best Courses for Statistics:
---------------------------------------------------------------------------------------------------------
+ Introduction to Statistics: bit.ly/3QkEgvM
+ Statistics with Python: bit.ly/3BfwejF
+ Statistics with R: bit.ly/3QkicBJ
Best Courses for Big Data:
---------------------------------------------------------------------------------------------------------
+ Google Cloud Data Engineering: bit.ly/3RjHJw6
+ AWS Data Science: bit.ly/3TKnoBS
+ Big Data Specialization: bit.ly/3ANqSut
More Courses:
---------------------------------------------------------------------------------------------------------
+ Tableau: bit.ly/3q966AN
+ Excel: bit.ly/3RBxind
+ Computer Vision: bit.ly/3esxVS5
+ Natural Language Processing: bit.ly/3edXAgW
+ IBM Dev Ops: bit.ly/3RlVKt2
+ IBM Full Stack Cloud: bit.ly/3x0pOm6
+ Object Oriented Programming (Java): bit.ly/3Bfjn0K
+ TensorFlow Advanced Techniques: bit.ly/3BePQV2
+ TensorFlow Data and Deployment: bit.ly/3BbC5Xb
+ Generative Adversarial Networks / GANs (PyTorch): bit.ly/3RHQiRj
Become a Member of the Channel! bit.ly/3oOMrVH
Follow me on LinkedIn! / greghogg
Full Disclosure:
Please note that I may earn a commission for purchases made at the above sites! I strongly believe in the material provided; I only recommend what I truly think is great. If you do choose to make purchases through these links; thank you for supporting the channel, it helps me make more free content like this!

Опубликовано:

 

18 май 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 14   
@Jonas-gm4my
@Jonas-gm4my 17 часов назад
The nth perfect square is the sum of the first n odd number, cant we just subtract odd numbers while the number is bigger or equal to zero and then check whether we are at 0 at the end?
@brycejohansen7114
@brycejohansen7114 23 дня назад
You could use Newton's Method which is O(log log n) because it converses quadratically.
@GregHogg
@GregHogg 23 дня назад
Yeah very true!
@LelouchVDK
@LelouchVDK 23 дня назад
I might be dumb, but putting it on the internet anyway. But wouldn't any square of an integer larger than the half of the original number already be bigger than the original number, meaning you could set the initial range to be from 1 to num // 2. Either way amazing question with an awesome solution from you
@GregHogg
@GregHogg 23 дня назад
Yes you could probably optimize the end range quite a bit. However because it's log and dividing by two each time, you'll only spare one or two iterations max anyway. Excellent observation. Thanks so much!
@user-vs5rh1oz3w
@user-vs5rh1oz3w 23 дня назад
please explain leetcode's "LAST DAY WHERE YOU CAN STILL CROSS" or "MINIMUM COST TO MAKE ARRAY EQUAL"
@GregHogg
@GregHogg 23 дня назад
I'll try to at some point :)
@mjanish9836
@mjanish9836 22 дня назад
brother, you can keep end = num//2 it actually reduces time
@GregHogg
@GregHogg 21 день назад
Cool thanks :)
@Xagittarius
@Xagittarius 23 дня назад
Cloud you guide a zigzag conversation
@GregHogg
@GregHogg 23 дня назад
What?
@Xagittarius
@Xagittarius 23 дня назад
@@GregHogg a zigzag conversation from leetcode
@GregHogg
@GregHogg 20 дней назад
@@Xagittarius I'll try to take a look at some point :)
Далее
Arcane Season 2 | Official Teaser Trailer
01:32
Просмотров 2,5 млн
Creepy Teacher Kidnapped My Girlfriend?!
00:42
Просмотров 13 млн
Binary Search Algorithm - Computerphile
18:34
Просмотров 155 тыс.
All 39 Python Keywords Explained
34:08
Просмотров 105 тыс.
A Simple Kafka and Python Walkthrough
11:34
Просмотров 4,3 тыс.
LSTM Time Series Forecasting Tutorial in Python
29:53
Просмотров 190 тыс.
Learn Binary search trees in 20 minutes 🔍
20:25
Просмотров 140 тыс.
Binary Search - Leetcode 704 - Python
9:40
Просмотров 129 тыс.
The Truth About Learning Python in 2024
9:38
Просмотров 118 тыс.
Arcane Season 2 | Official Teaser Trailer
01:32
Просмотров 2,5 млн