0:00 / 0:00
Zero sum triplets in Kotlin
Dmitry Kandalov
532 subscribers • 3 videos on Hallway
- Recommended by 1 person: 1 in engineering communities.
- Presented by Dmitry Kandalov
Intermediate. Assumes working knowledge.
1K views5 years ago1 recommendation
Computer scienceProgramming languagesAlgorithmsKotlinData structures
Dmitry Kandalov demonstrates solving the 3SUM problem in Kotlin, starting with an O(n^3) approach and optimizing it to O(n^2).
In this (not a tutorial) video I'm doing zero sum triplets exercise in way you would never do it during a coding interview (and that's a shame). I start with n^3 and finish with n^2 time complexity solution leaving fancy FFT things and more rants for another time. Timecodes: - Intro - Problem description - Improving threeSum() function definition - O(n^3) implementation with three nested loops - Test "example 1" (failing because of Triplet equality) - Making test pass by introducing Triplet data class - Refactoring findZeroSumTriplets() - Test "performance on large input" (failing on timeout) - O(n^2) two-pointer implementation - Solution overview - Final thoughts Links: Subset sum problem — en.wikipedia.org/wiki/Subset_sum_problem 3SUM problem — en.wikipedia.org/wiki/3SUM The exercise on leetcode — leetcode.com/problems/3sum Kotlin programming language — kotlinlang.org JUnit5 — junit.org/junit5 Fast Fourier transform (FFT) — en.wikipedia.org/wiki/Fast_Fourier_transform Dmitry on Twitter — twitter.com/dmitrykandalov Intro/outro music by Strobes (strobesband.bandcamp.com) #3SUM #ZeroSumTriplets #Kotlin #CodingInterview #LeetCode #LiveCoding