Find the Min and Max Integer Value In Arrays using Go

This blog post is a part of a series on programming interview questions. In this blog post, I will show you how to find the min and max integer in Go Arrays or Slices. You can find more interview questions blog post here.

Sometimes an interviewer will ask you to find the min integer value in an array or to find the max integer value. The easiest to solve these two problems would be to sort the Array. This way you could return the zero index for the array of the Min Value and the last index for the Max Value. But the interviewer more and likely will not allow you to sort the array.

Find The Min integer Value In an Array

To find the Min integer value we will create a variable to track the min value.  We do this by setting the Min variable to math.MaxInt64.

You can run this code on the Go Playground here.

Find The Max integer Value In an Array

To find the Max integer value we will create a variable to track the max value. We do this by setting the Max variable to math.MinInt64.

You can run this code on the Go Playground here.

Conclusion

In this blog post, you learn how to find the Min integer value in an Array and how to find the Max integer value in an Array.

About the Author Harrison Brock

Harrison Brock is a software engineer that focuses on Full Stack web development

follow me on: