Re: [闲聊] 每日LeetCode

楼主: Rushia (みけねこ的鼻屎)   2024-01-15 13:08:56
https://leetcode.com/problems/find-players-with-zero-or-one-losses
2225. Find Players With Zero or One Losses
给你一个二维阵列matches[][],matches[i] = {wini, loseri} 表示第i场比赛
wini打赢了loseri,返回一个二维列表,第一个列表为没输过的玩家,第二个列表
为只输一场的玩家,列表中的id升序排列。
思路:
1.统计所有玩家的败场数,把败场为0和败场为1的抓出来即可,可以用HashMap
或是int[]计数并排除掉没出现的id。
Java Code:

Links booklink

Contact Us: admin [ a t ] ucptt.com