Buy Me a Coffee

[HackerRank] Simple Explanation: Flatland Space Stations

Introduction Although the problem is categorized as “EASY” in terms of difficulty, I must admit that the solution didn’t immediately come to mind after reading the description. Nevertheless, I managed to find a straightforward and concise approach that is both easy to comprehend and implement. I won’t explain the requirement here, so before reading the below explanation, I highly suggested that making sure we understand this problem’s description. The challenge description can be found https://www.hackerrank.com/challenges/flatland-space-stations/problem ...

[Golang] reflect all

This post is about how to use reflect feature to implement as much as you want to do with Golang. Here are some cases: 1. How to get all the fields’ name of an object? 1type A struct{ 2 Foo string 3 Bar int64 4} 5 6func main() { 7 a := &A{Foo: "afoo"} 8 val := reflect.ValueOf(a).Elem() 9 for i:=0; i<val.NumField();i++{ 10 fmt.Println(val.Type().Field(i).Name) 11 } 12} The output: ...

DigitalOcean Referral Badge
Sign up to get $200, 60-day account credit !