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 15%
tree
Steffan
#2
74 c.
Top 23%
madeforlosers
#3
85 c.
Top 31%
voytxt
#4
101 c.
Top 38%
Shanethegamer
#5
103 c.
Top 46%
Natanaelel
#6
104 c.
Top 54%
Thomasdcrt
#7
107 c.
Top 62%
maximec-indy
#8
117 c.
Top 69%
davyboyh
#9
119 c.
Top 77%
Mif712
#10
135 c.
Top 85%
SephQ
#11
146 c.
Top 92%
ComputerKWasTaken
#12
210 c.
Top 100%
scpchicken