Skip to content

Commit c49cbe0

Browse files
26
1 parent dd58020 commit c49cbe0

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

Diff for: 26 Remove Duplicates from Sorted Array/solution.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 26. Remove Duplicates from Sorted Array
2+
# https://leetcode.com/problems/remove-duplicates-from-sorted-array/description/
3+
4+
nums = [0,0,1,1,1,2,2,3,3,4]
5+
6+
# nums = [1,2]
7+
def duplicate(nums):
8+
if len(nums) <= 1:
9+
return len(nums)
10+
11+
po1 = 1
12+
13+
for po2 in range(1, len(nums)):
14+
if nums[po2] != nums[po2 - 1]:
15+
nums[po1] = nums[po2]
16+
po1 += 1
17+
18+
return po1
19+
20+
21+
print(duplicate(nums))

Diff for: 2923_ Find Champion I/solution.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# 2923. Find Champion I
2+
# Easy
3+
# Topics
4+
# Companies
5+
# Hint
6+
# There are n teams numbered from 0 to n - 1 in a tournament.
7+
#
8+
# Given a 0-indexed 2D boolean matrix grid of size n * n. For all i, j that 0 <= i, j <= n - 1 and i != j team i is stronger than team j if grid[i][j] == 1, otherwise, team j is stronger than team i.
9+
# Team a will be the champion of the tournament if there is no team b that is stronger than team a.
10+
#
11+
# Return the team that will be the champion of the tournament.
12+
# Example 1:
13+
#
14+
# Input: grid = [[0,1],[0,0]]
15+
# Output: 0
16+
# Explanation: There are two teams in this tournament.
17+
# grid[0][1] == 1 means that team 0 is stronger than team 1. So team 0 will be the champion.
18+
# Example 2:
19+
#
20+
# Input: grid = [[0,0,1],[1,0,1],[0,0,0]]
21+
# Output: 1
22+
# Explanation: There are three teams in this tournament.
23+
# grid[1][0] == 1 means that team 1 is stronger than team 0.
24+
# grid[1][2] == 1 means that team 1 is stronger than team 2.
25+
# So team 1 will be the champion.
26+
27+
grid = [[0,1],[0,0]]
28+
29+
def winner(grid) -> int:
30+
...
31+
32+
33+
34+
winner(grid)

0 commit comments

Comments
 (0)