Skip to content

Instantly share code, notes, and snippets.

View 4ver's full-sized avatar
💭
thinking

Donal Linehan 4ver

💭
thinking
View GitHub Profile
/**
* @param {number[]} ratings
* @return {number}
*/
var candy = function(ratings) {
const isHigherValues = ratings.map((rating, index) => {
return rating > (ratings[index - 1] || 10000000) || rating > (ratings[index + 1] || 10000000)
})
const isHigherGroups = isHigherValues.reduce((prev, isHigher) => {