<commit_before>package leetcode

/**
 * https://leetcode.com/problems/sum-of-beauty-in-the-array/
 */
class Problem2012 {
    fun sumOfBeauties(nums: IntArray): Int {
        TODO()
    }
}

fun main() {
    val prob = Problem2012()
    println(prob.sumOfBeauties(intArrayOf(1,2,3))) // 2
    println(prob.sumOfBeauties(intArrayOf(2,4,6,4))) // 1
    println(prob.sumOfBeauties(intArrayOf(2,4,6,5))) // 2
    println(prob.sumOfBeauties(intArrayOf(2,4,6,6))) // 2
    println(prob.sumOfBeauties(intArrayOf(2,4,6,7))) // 4
    println(prob.sumOfBeauties(intArrayOf(2,4,6,7,8,6))) // 4
    println(prob.sumOfBeauties(intArrayOf(2,4,6,7,8,4))) // 3
    println(prob.sumOfBeauties(intArrayOf(3,2,1))) // 0
}<commit_msg>Solve problem 2012<commit_after>package leetcode

import kotlin.math.max
import kotlin.math.min

/**
 * https://leetcode.com/problems/sum-of-beauty-in-the-array/
 */
class Problem2012 {
    fun sumOfBeauties(nums: IntArray): Int {
        val left = IntArray(nums.size)
        for ((i, n) in nums.withIndex()) {
            left[i] = if (i == 0) n else max(left[i - 1], n)
        }
        val right = IntArray(nums.size)
        for (i in nums.size - 1 downTo 0) {
            right[i] = if (i == nums.size - 1) nums[i] else min(right[i + 1], nums[i])
        }
        var answer = 0
        for (i in 1..nums.size - 2) {
            if (left[i - 1] < nums[i] && nums[i] < right[i + 1]) {
                answer += 2
            } else if (nums[i - 1] < nums[i] && nums[i] < nums[i + 1]) {
                answer++
            }
        }
        return answer
    }
}
{'fraction_non_alphanumeric': 0.17276166456494324, 'fraction_numerical': 0.04539722572509458, 'mean_word_length': 2.3340336134453783, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3002817', 'n_tokens_mistral': 676, 'n_tokens_neox': 627, 'n_words': 111}