Skip to content

Instantly share code, notes, and snippets.

View rtsoy's full-sized avatar
:octocat:

Roman rtsoy

:octocat:
  • Astana, Kazakhstan
View GitHub Profile
@rtsoy
rtsoy / top-k-frequent-words.go
Created January 3, 2026 05:14
692. Top K Frequent Words
// https://leetcode.com/problems/top-k-frequent-words/
//
// Time: O(n log k)
// Space: O(n)
//
// n = number of unique words in array
// .................... //
type item struct {
@rtsoy
rtsoy / top-k-frequent-elements.go
Created January 3, 2026 05:24
347. Top K Frequent Elements
// https://leetcode.com/problems/top-k-frequent-elements/
//
// Time: O(n log k)
// Space: O(n)
//
// n - number of unique elements in array
// .................... //
type item struct {
@rtsoy
rtsoy / merge-intervals.go
Created January 3, 2026 05:36
56. Merge Intervals
// https://leetcode.com/problems/merge-intervals/
//
// Time: O(n log n)
// Space: O(n)
//
// n = number of intervals
// .................... //
func merge(intervals [][]int) [][]int {
@rtsoy
rtsoy / container-with-most-water.go
Created January 3, 2026 05:54
11. Container With Most Water
// https://leetcode.com/problems/container-with-most-water/
//
// Time: O(n)
// Space: O(1)
//
// n = number of elements in array
// .................... //
func maxArea(height []int) int {
@rtsoy
rtsoy / partition-labels.go
Created January 3, 2026 06:18
763. Partition Labels
// https://leetcode.com/problems/partition-labels/
//
// Time: O(n)
// Space: O(1)
//
// n = number of letters in string
// .................... //
func partitionLabels(s string) []int {
@rtsoy
rtsoy / longest-repeating-character-replacement.go
Created January 5, 2026 18:23
424. Longest Repeating Character Replacement
// https://leetcode.com/problems/longest-repeating-character-replacement/
//
// Time: O(n)
// Space: O(1)
//
// n = number of letters in string
// .................... //
func characterReplacement(s string, k int) int {
@rtsoy
rtsoy / sliding-window-maximum.go
Created January 6, 2026 15:49
239. Sliding Window Maximum
// https://leetcode.com/problems/sliding-window-maximum
//
// Time: O(n)
// Space: O(n)
//
// n = number of elements in array
// .................... //
func maxSlidingWindow(nums []int, k int) []int {