Gyanthakur/awesome-dsa-solutions

Largest Element in Array

Open

#14 opened on Oct 23, 2025

 (3 comments) (0 reactions) (1 assignee)Java (6 forks)auto 404
good first issuehacktoberfesthacktoberfest-acceptedhacktoberfest_2025starters

Repository metrics

Stars
 (5 stars)
PR merge metrics
 (PR metrics pending)

Description

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.

Contributor guide