leetcode594】的更多相关文章

We define a harmonious array is an array where the difference between its maximum value and its minimum value is exactly 1. Now, given an integer array, you need to find the length of its longest harmonious subsequence among all its possible subseque…
public class Solution { public int FindLHS(int[] nums) { Dictionary<int, int> dic = new Dictionary<int, int>(); foreach (var num in nums) { if (!dic.ContainsKey(num)) { dic.Add(num, ); } else { dic[num]++; } } var list = dic.OrderBy(x => x.…