Data Structure & Algorithm: Level-1 Problem #10. Assign Stalls

Given the heights for a list of cows and a list of stalls, one stall can only hold one cow with the same or less height. Find out the maximum number of cows that could be assigned to the stalls.

Sample Input:

cows height = [15,19,13,4,9,16,7]
stalls height = [10,15,12,7,21,33,5]

Sample Output:

6

From the above sample input, we could find stalls for 6 cows.


数据结构和算法:初级练习题# 10 – 分配牛棚


给定一组牛的身高和一组牛棚的高度,统计最多可以让几头牛住进牛棚。每个牛棚只能入住一头牛,牛的高度不能超过牛棚的高度。

样例输入:

cows height = [15,19,13,4,9,16,7]
stalls height = [10,15,12,7,21,33,5]

样例输出:

6

上面的输入样例中,我们可以最多分配6头牛入住牛棚。


Python Solution

Find Stalls