Peaks And Lows

Find the peaks and lows in a given array of integers.

Medium1/15/2024

Problem statement

Given an array of integers, find the local peaks and lows (local extremums) in the array. Return a string with a P for each peak, an L for each low and a - for each other element.

Notes:

  • Start and end elements are either peaks or lows
  • There are no consecutive identical numbers

Problem leaderboard

#
Size
%
Users
#1
72 c.
Top 22%
tree
Steffan
#2
85 c.
Top 33%
voytxt
#3
101 c.
Top 44%
Shanethegamer
#4
103 c.
Top 56%
Natanaelel
#5
104 c.
Top 67%
Thomasdcrt
#6
107 c.
Top 78%
maximec-indy
#7
117 c.
Top 89%
davyboyh
#8
210 c.
Top 100%
scpchicken