330. Min Element in Linked List

EasyLinked ListLinked ListTraversalMin

Given the head of a singly linked list, return the minimum value among all node values.

Input: Head of a singly linked list (at least one node).

Output: Integer — minimum node value.

Examples

Example 1
Input: [3,1,4,1,5,9,2,6]
Output: 1
Explanation: Traverse all; min is 1.
Example 2
Input: [-5,-1,-3]
Output: -5
Explanation: All negatives; min is -5.
Example 3
Input: [7]
Output: 7
Explanation: Single node; min is 7.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →