int heightChecker(int* heights, int heightsSize){ int hash[101]={0}; int i,j,count=0; for (i=0; i<heightsSize; i++) hash[heights[i]]++; for (i=0,j=1; i<heightsSize; j++) while(hash[j]-- > 0) if (heights[i++] != j) count++; return count; }
int heightChecker(int* heights, int heightsSize){ int hash[101]={0}; int i,j,count=0; for (i=0; i<heightsSize; i++) hash[heights[i]]++; for (i=0,j=1; i<heightsSize; j++) while(hash[j]-- > 0) if (heights[i++] != j) count++; return count; }
上一篇:【leetcode】 汉明距离
下一篇:【leetcode】供暖器
【LeetCode】39. 组合总和
【LeetCode】705. 设计哈希集合
【LeetCode】706. 设计哈希映射
<= heights.length <= ...
点 ai 和 bi 之间存在一条无向边。可选择树中任何一个节点作为根。当选择节点 x 作为根节点时,设结果树的高度为
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M