Skip to content

Latest commit

 

History

History
29 lines (26 loc) · 1.63 KB

File metadata and controls

29 lines (26 loc) · 1.63 KB

统计数组中的元素个数 中等

by 凤之兮原 @kongmingLatern

接受挑战    English

通过实现一个CountElementNumberToObject方法,统计数组中相同元素的个数

type Simple1 = CountElementNumberToObject<[]> // return {}
type Simple2 = CountElementNumberToObject<[1,2,3,4,5]> 
/*
 return {
  1: 1,
  2: 1,
  3: 1,
  4: 1,
  5: 1
}
*/
type Simple3 = CountElementNumberToObject<[1,2,3,4,5,[1,2,3]]> 
/*
 return {
  1: 2,
  2: 2,
  3: 2,
  4: 1,
  5: 1
}
*/

返回首页 分享你的解答 查看解答