Gyanthakur/awesome-dsa-solutions

Largest Element in Array

Aperta

#14 aperta il 23 ott 2025

 (3 commenti) (0 reazioni) (1 assegnatario)Java (6 fork)auto 404
good first issuehacktoberfesthacktoberfest-acceptedhacktoberfest_2025starters

Metriche repository

Star
 (5 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Given an array of integers, your task is to find and return the largest element in the array. The largest element is the number that has the highest value among all elements in the array.

You must write an efficient algorithm that works for both positive and negative numbers. If the array is empty, handle it appropriately (e.g., raise an error or return a special value).

Input An integer array arr of size n (where n > 0).

Output A single integer — the largest element in the array.

Guida contributor