LeetCode 1552 - Magnetic Force Between Two Balls - Java

  Рет қаралды 589

Alpha-Code

Alpha-Code

Ай бұрын

Solution, explanation, and complexity analysis for LeetCode 1552 in Java
Problem Description:
leetcode.com/problems/magneti...
Code:
github.com/AnatoliySokolov98/...

Пікірлер: 6
@rostyslavmochulskyi159
@rostyslavmochulskyi159 Ай бұрын
In Java, Arrays.sort() is implemented using a variant of the Quick Sort algorithm which has a space complexity of O(logn) for sorting
@Alpha-Code
@Alpha-Code Ай бұрын
Gotcha, I think in Python its also not O(1) for sort but most people write it that way.
@margin100px
@margin100px Ай бұрын
Cool thumbnail!!
@MehdiKhfifi
@MehdiKhfifi Ай бұрын
i don't understand why the left position has to be 1 and not 0?
@tzuilee588
@tzuilee588 Ай бұрын
it doesn't matter if it's 0 or 1, we are binary searching the gap not the array index
@Alpha-Code
@Alpha-Code Ай бұрын
It wouldn't matter, but also if you have enough buckets to put the balls in if it was zero you'd put every ball in the same bucket which wouldn't make sense. You can always put the balls in different buckets and the minimum space between buckets is 1.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 393 М.
World’s Largest Jello Pool
01:00
Mark Rober
Рет қаралды 101 МЛН
IQ Level: 10000
00:10
Younes Zarou
Рет қаралды 10 МЛН
Fast and Furious: New Zealand 🚗
00:29
How Ridiculous
Рет қаралды 43 МЛН
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 632 М.
Leetcode 443: String Compression | Detailed Explanation
10:28
Comprehensive Code
Рет қаралды 41
LeetCode 1552. Magnetic Force Between Two Balls (Python)
8:11
Water powered timers hidden in public restrooms
13:12
Steve Mould
Рет қаралды 692 М.
Andrew Kelley   Practical Data Oriented Design (DoD)
46:40
ChimiChanga
Рет қаралды 61 М.
1552. Magnetic Force Between Two Balls - Day 20/30 Leetcode June Challenge
9:33
Programming Live with Larry
Рет қаралды 982
Magnetic Force Between Two Balls | Leetcode 1552
18:00
Ayushi Sharma
Рет қаралды 1,6 М.
LeetCode 2976 - Minimum Cost To Convert String I - Java
15:49
World’s Largest Jello Pool
01:00
Mark Rober
Рет қаралды 101 МЛН