leetcode414

Posted AsenYang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode414相关的知识,希望对你有一定的参考价值。

public class Solution {
    public int ThirdMax(int[] nums) {
        var third = 0;

            var list = nums.Distinct().OrderByDescending(x => x).ToList();
            if (list.Count == 0)
            {
                third = 0;
            }
            else if (list.Count >= 1 && list.Count <= 2)
            {
                third = list[0];
            }
            else
            {
                third = list[2];
            }
            return third;
    }
}

https://leetcode.com/problems/third-maximum-number/#/description

以上是关于leetcode414的主要内容,如果未能解决你的问题,请参考以下文章