Leetcode Note: Go - Count Elements With Strictly Smaller and Greater Elements

Count Elements With Strictly Smaller and Greater Elements - LeetCode
https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements/

  • Go 言語で取り組んだメモ

回答

Golang w/o map. Sorting time n*log(n) space 0(1) - Count Elements With Strictly Smaller and Greater Elements - LeetCode
https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements/solutions/3206128/golang-w-o-map-sorting-time-n-log-n-space-0-1/

func countElements(nums []int) (res int) {
    sort.Ints(nums)

    for _, v := range nums {
        if  v != nums[0] && v != nums[len(nums)-1] {
         res++
        }
    }
    return
}