FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Finding the Maximum and Minimum Element in an Array
How-ToProgramming Languages

Finding the Maximum and Minimum Element in an Array

via Dev.to PythonJeyaprasad R4h ago

In this task, I worked on finding the minimum and maximum values from an array. Instead of writing everything in one place, I used a function to make the code cleaner and reusable. What I Did I created a function called find_min_max that takes an array as input and returns both the smallest and largest values. For example: Input: [1, 4, 3, 5, 8, 6] Output: [1, 8] How I Solved It First, I assumed that the first element of the array is both the minimum and maximum. Then I used a loop to go through each number in the array. While looping: If a number is smaller than the current minimum, I update the minimum If a number is larger than the current maximum, I update the maximum At the end, I return both values as a list. Code def find_min_max ( arr ): minimum = arr [ 0 ] maximum = arr [ 0 ] for num in arr : if num < minimum : minimum = num if num > maximum : maximum = num return [ minimum , maximum ] print ( find_min_max ([ 1 , 4 , 3 , 5 , 8 , 6 ])) print ( find_min_max ([ 12 , 3 , 15 , 7 ,

Continue reading on Dev.to Python

Opens in a new tab

Read Full Article
0 views

Related Articles

Hermès doesn’t include a power adapter with its $5,150 charging case
How-To

Hermès doesn’t include a power adapter with its $5,150 charging case

The Verge • 34m ago

All the wrong EVs are getting cancelled
How-To

All the wrong EVs are getting cancelled

The Verge • 1h ago

Building Backend Auth System with Swagger and Clean Structure
How-To

Building Backend Auth System with Swagger and Clean Structure

Medium Programming • 2h ago

7 Mistakes Every Junior Developer Makes
How-To

7 Mistakes Every Junior Developer Makes

Medium Programming • 2h ago

Epic and Disney now let Fortnite creators make Star Wars games
How-To

Epic and Disney now let Fortnite creators make Star Wars games

The Verge • 3h ago

Discover More Articles