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 Minimum and Maximum in an Array Using Linear Search in Python
NewsProgramming Languages

Finding Minimum and Maximum in an Array Using Linear Search in Python

via Dev.to PythonSri Mahalakshmi3h ago

Problem Explanation Given an array arr[] , the task is to find the minimum and maximum elements in the array. Example: Input: arr = [1, 4, 3, 5, 8, 6] Output: [1, 8] Input: arr = [12, 3, 15, 7, 9] Output: [3, 15] Method Used: Linear Search We traverse the array once and keep track of: The smallest value (minimum) The largest value (maximum) Why This Method? Time complexity is O(n) (only one traversal) Space complexity is O(1) (no extra space used) Simple and efficient for this problem Python Code class Solution : def getMinMax ( self , arr ): minimum = arr [ 0 ] maximum = arr [ 0 ] for num in arr : if num < minimum : minimum = num if num > maximum : maximum = num return [ minimum , maximum ] Code Explanation (Line by Line) class Solution: Defines the class as required by the platform. def getMinMax(self, arr): Function to find minimum and maximum values. minimum = arr[0] Initialize minimum with the first element. maximum = arr[0] Initialize maximum with the first element. for num in ar

Continue reading on Dev.to Python

Opens in a new tab

Read Full Article
0 views

Related Articles

Online age checks came first — a VPN crackdown could be next
News

Online age checks came first — a VPN crackdown could be next

The Verge • 13m ago

I Built a Simple Pine Script Strategy in 30 Lines — Here Are the Backtest Results (And Why You…
News

I Built a Simple Pine Script Strategy in 30 Lines — Here Are the Backtest Results (And Why You…

Medium Programming • 32m ago

Extreme Gradient Boosting (XGBoost): Concepts, Differences, and Implementation
News

Extreme Gradient Boosting (XGBoost): Concepts, Differences, and Implementation

Medium Programming • 1h ago

Give Your Phone a Huge (and Free) Upgrade by Switching to Another Keyboard
News

Give Your Phone a Huge (and Free) Upgrade by Switching to Another Keyboard

Wired • 1h ago

Title: February 2026: The Final Month for STON/USDT V2 Protection
News

Title: February 2026: The Final Month for STON/USDT V2 Protection

Medium Programming • 2h ago

Discover More Articles