Identical Elements - aloalgo

Identical Elements

Very Easy

You are given an integer array nums.

Your task is to determine whether all elements in the array have the same value.

You may assume that:

  • The array will contain at least one element.

Return true if every element in the array is identical, otherwise return false.

Example 1

Input
[5, 5, 5, 5]
Output
True
Explanation:

All elements are 5, so we return true.

Example 2

Input
[1, 1, 2, 1]
Output
False
Explanation:

The array contains both 1 and 2, so we return false.

Example 3

Input
[7]
Output
True
Explanation:

There is only one element, so all elements are trivially identical.

Loading...
Input
[5, 5, 5, 5]
Output
True

Hello! I am your ✨ AI assistant. I can provide you hints, explanations, give feedback on your code, and more. Just ask me anything related to the problem you're working on!