Skip to content

Instantly share code, notes, and snippets.

// https://go.dev/play/p/RKU8IstAlhf
// Does close() signals select? Yes
// Is channel picked randomly? Yes
// If there is long buffered channel with many entries will cancel() / other channel be triggered? Yes
package main
import (
"fmt"
"time"
)
// 🍍🍌πŸ₯πŸπŸŒπŸ₯πŸπŸŒπŸ₯πŸπŸŒπŸ₯πŸπŸŒπŸ₯πŸπŸŒπŸ₯
// time: O(N)
// space: O(1)
// why: making smoothie! 🍧
package main
import (
"fmt"
"math/rand"
)
@nikolaydubina
nikolaydubina / check_cycle_in_inifinite_single_linked_list.go
Created November 26, 2021 15:43
check_cycle_in_inifinite_single_linked_list.go
// πŸŽ„πŸŽ„πŸŽ„πŸŽ„πŸŽ„πŸŽ„πŸŽ„πŸ¦ŒπŸ¦ŒπŸ¦ŒπŸ¦ŒπŸ¦ŒπŸ¦ŒπŸ¦ŒπŸ¦ŒπŸ¦ŒπŸŽ…πŸ»πŸŽπŸŽπŸŽπŸŽ„πŸŽ„πŸŽ„πŸŽ„
// time: O(N)
// space: O(1)
// Go Playground: https://go.dev/play/p/1g8m82vmuuu
// why: Merry Christmas!
package main
import "fmt"
type Node struct {
@nikolaydubina
nikolaydubina / reverse_infinite_single_linked_list.go
Created November 26, 2021 14:35
reverse_infinite_single_linked_list.go
// Go Playground: https://go.dev/play/p/DMiZPwRUGWD
// time: O(N)
// space: O(1)
// why: Just For Fun! πŸ€ͺ
package main
import "fmt"
type Node struct {
V string