Lua Coding Practice

Solve Find Peak Elements using Lua Language

Solve Find Peak Elements using Lua to enhance your skills with lua coding practice , master coding concepts, and prepare for interviews with practical exercises and detailed solutions.

Find Peak Elements

Difficulty : Easy

Categories :

  • Arrays

Given an array of integers, find the peak element(s). A peak element is one that is greater than both its adjacent elements. For edge elements, compare only with the adjacent element. Return an array containing the indices of all peak elements.

Constraints:

  • 1 ≤ arr.length ≤ 10⁴
  • -10⁴ ≤ arr[i] ≤ 10⁴
  • Elements can appear multiple times
  • Return indices in ascending order

Examples:

Input: arr = [1,3,2,4,1,5,2]
Output: [1,3,5]
Explanation: Peak elements are at indices: 1 (value 3), 3 (value 4), and 5 (value 5)
Input: arr = [1,2,3,4,5]
Output: [4]
Explanation: Only the last element is a peak
Input: arr = [5,4,3,2,1]
Output: [0]
Explanation: Only the first element is a peak

Problem Solving

Input

What You'll Find Here

Real-World Applications Solve problems inspired by Lua's common use cases, such as game development and embedded systems.

Step-by-Step Guidance Break down Lua's concepts into digestible lessons.

Practical Skills Build hands-on experience with Lua for real-world projects.

Choose from the following categories