Skip to content

Instantly share code, notes, and snippets.

@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
@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 {
// 🍍🍌🥝🍍🍌🥝🍍🍌🥝🍍🍌🥝🍍🍌🥝🍍🍌🥝
// time: O(N)
// space: O(1)
// why: making smoothie! 🍧
package main
import (
"fmt"
"math/rand"
)
// 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"
)
// I am applying function on two things and they tell me how 🐁
// https://go.dev/play/p/8iGGh8Tebgw
package main
import "fmt"
type Summer interface {
Sum(other Summer) Summer
}
// format string slice strings with whitespace can collide 🤪
// https://go.dev/play/p/EqnE9ZWHcjh
package main
import "fmt"
func main() {
fmt.Printf("%v\n", []string{"a b", "c"})
fmt.Printf("%v\n", []string{"a", "b", "c"})
package main
import (
"errors"
"fmt"
"unsafe"
)
type Currency uint8
// https://go.dev/play/p/mcWx20GtkaO
// 🌊
package main
import "fmt"
type SGD int64
func (as SGD) Add(bs SGD) SGD { return as + bs }
// https://go.dev/play/p/oyMTzj-WQRq
package main
import "fmt"
func main() {
x := "‌"
if x != "" {
panic("no.way.")
}

144.96

package main

import "fmt"

func main() {
	var x float32 = 144.96
	var y float64 = 144.96