Sign in

The problem’s link:

This problem’s difficulty level is EASY, but to be honest, the solution didn’t pop up into my mind straight away after reading the description. However, I found one way which is easy understanding and light code to solve it.

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 sample input is

5 2
0 4
Maximum distance to reach the nearest space station

Okay. It means that there are 5 cities and 2 of them have a space station, and these two cities are respectively 0 and 4. The…

Circle CI is a CI/CD service, which is quite convenient to help you deploy your code to the remote server. This post aims to provide a solution to one frustrating problem that you probably met with CircleCI, which is not enough information to prompt when your program stops at the compiling stage. Simply like the picture below:

Here is the concept of the solution. We can create a container based on the same docker image that you used in CircleCI and run the compile command of your program in this docker. …

In real projects, it is common to increase the EBS volumes on the EC2 as the project develops deeper and further. In this module, I will lead you to finish it step by step:

Important to notice that creating a snapshot of the target’s volume before resizing volume is always a secure way. Go to your EC2 dashboard -> Elastic block store -> Volumes, in the Actions you can find Create Snapshot.

1. Increasing disk space

In Volumes -> Actions, you can choose to Modify Volume to increase the size of the volume (only allow the upgrade, not downgrade).

2. Resizing a Linux partition

Log in your EC2 instance…

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?

type A struct{
Foo string
Bar int64
func main() {
a := &A{Foo: "afoo"}
val := reflect.ValueOf(a).Elem()
for i:=0; i<val.NumField();i++{

The answer:


Tips: 1. Use .Elem after reflect.ValueOf(a) , because the variable a is a pointer. If a is an object, we can get the same result as below code

a := A{Foo:"afoo"}
val := reflect.ValueOf(a)

2. val.Field(i).Type().Name is totally different from val.Type().Field(i).Name . …

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store