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 14 күн бұрын
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 14 күн бұрын
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 12 күн бұрын
Cool thanks :)
@Xagittarius
@Xagittarius 14 күн бұрын
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
Binary Search - Leetcode 704 - Python
9:40
NeetCode
Рет қаралды 126 М.
어른의 힘으로만 할 수 있는 버블티 마시는법
00:15
진영민yeongmin
Рет қаралды 9 МЛН
Sprinting with More and More Money
00:29
MrBeast
Рет қаралды 59 МЛН
КАРМАНЧИК 2 СЕЗОН 6 СЕРИЯ
21:57
Inter Production
Рет қаралды 437 М.
Programming a Guessing Game in Rust!
13:22
Let's Get Rusty
Рет қаралды 103 М.
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 53 М.
Python in 2024 ❌or ✔️
0:47
CodeWithHarry
Рет қаралды 284 М.
Let's Solve Leetcode 461 - Python - Hamming Distance
4:24
Sam Does Leetcode
Рет қаралды 79
Learn Binary search trees in 20 minutes 🔍
20:25
Bro Code
Рет қаралды 136 М.
Koko Eating Bananas - Binary Search - Leetcode 875 - Python
15:12
For loops in Python are easy 🔁
5:06
Bro Code
Рет қаралды 237 М.
어른의 힘으로만 할 수 있는 버블티 마시는법
00:15
진영민yeongmin
Рет қаралды 9 МЛН