Priority Queue Min
Published at25 Jul 2026
Created by M Ichsanul Fadhil
Find the minimum value in an array (simulating peeking at the smallest element in a min-priority queue). Return -1 if empty.
Example Input & Output
Example 1
Input
[10,5,7]
Output
5
Explanation
Min is 5
Example 2
Input
[42]
Output
42
Explanation
Single element
Example 3
Input
[3,1,4,1,5]
Output
1
Explanation
Min is 1
Example 4
Input
[]
Output
-1
Explanation
Empty
Example 5
Input
[-5,0,3]
Output
-5
Explanation
Negative min
Algorithm Flow

Recommendation Algorithm Flow for Priority Queue Min
Solution Approach
Best Answers
java
class Solution {
public int solution(int[] nums) {
if(nums.length==0)return -1;int m=nums[0];for(int n:nums){if(n<m)m=n;}return m;
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
