We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2d10c37 commit 1ca1314Copy full SHA for 1ca1314
Python/rank-teams-by-votes.py
@@ -0,0 +1,15 @@
1
+# Time: O(m * (n + mlogm)), n is the number of votes
2
+# , m is the length of vote
3
+# Space: O(m^2)
4
+
5
+class Solution(object):
6
+ def rankTeams(self, votes):
7
+ """
8
+ :type votes: List[str]
9
+ :rtype: str
10
11
+ count = {v: [0]*len(votes[0]) + [v] for v in votes[0]}
12
+ for vote in votes:
13
+ for i, v in enumerate(vote):
14
+ count[v][i] -= 1
15
+ return "".join(sorted(votes[0], key=count.__getitem__))
0 commit comments