题解 | #牛的品种排序III#

牛的品种排序III

https://www.nowcoder.com/practice/f6ab3d7e20f54860886848f0a6374987

from re import M
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 
# @param cows int整型一维数组 
# @param k int整型 
# @return int整型一维数组
#
class Solution:
    def sortCowsIII(self , cows: List[int], k: int) -> List[int]:
        # write code here
        g = [0]*k
        for i in cows:
            g[i]=g[i]+1
        print(g)
        f=[]
        for i in range(k):
            cur = []
            cur = [i]*g[i]
            print(cur)
            f = f + cur
        return f

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务