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

  Рет қаралды 1,132

Greg Hogg

Greg Hogg

15 күн бұрын

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!

Пікірлер: 13
@brycejohansen7114
@brycejohansen7114 13 күн бұрын
You could use Newton's Method which is O(log log n) because it converses quadratically.
@GregHogg
@GregHogg 13 күн бұрын
Yeah very true!
@LelouchVDK
@LelouchVDK 13 күн бұрын
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 13 күн бұрын
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 13 күн бұрын
please explain leetcode's "LAST DAY WHERE YOU CAN STILL CROSS" or "MINIMUM COST TO MAKE ARRAY EQUAL"
@GregHogg
@GregHogg 13 күн бұрын
I'll try to at some point :)
@mjanish9836
@mjanish9836 12 күн бұрын
brother, you can keep end = num//2 it actually reduces time
@GregHogg
@GregHogg 11 күн бұрын
Cool thanks :)
@Xagittarius
@Xagittarius 13 күн бұрын
Cloud you guide a zigzag conversation
@GregHogg
@GregHogg 13 күн бұрын
What?
@Xagittarius
@Xagittarius 13 күн бұрын
@@GregHogg a zigzag conversation from leetcode
@GregHogg
@GregHogg 10 күн бұрын
@@Xagittarius I'll try to take a look at some point :)
Koko Eating Bananas - Leetcode 875 - Binary Search (Python)
13:34
когда достали одноклассники!
00:49
БРУНО
Рет қаралды 3,4 МЛН
How I prepare to meet the brothers Mbappé.. 🙈 @KylianMbappe
00:17
Celine Dept
Рет қаралды 54 МЛН
Binary Search Algorithm - Computerphile
18:34
Computerphile
Рет қаралды 155 М.
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 53 М.
All 39 Python Keywords Explained
34:08
Indently
Рет қаралды 95 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 109 М.
3Sum - Leetcode 15 - 2 Pointers (Python)
9:42
Greg Hogg
Рет қаралды 3,3 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 589 М.
Binary search in 4 minutes
4:00
Michael Sambol
Рет қаралды 99 М.
Fibonacci Number - Leetcode 509 - Dynamic Programming (Python)
19:05
The Truth About Learning Python in 2024
9:38
Internet Made Coder
Рет қаралды 108 М.
когда достали одноклассники!
00:49
БРУНО
Рет қаралды 3,4 МЛН