Skip to content

Commit

Permalink
Leetcode Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SKAUL05 committed Apr 17, 2024
1 parent 786fa7b commit ff704ca
Show file tree
Hide file tree
Showing 45 changed files with 179 additions and 338 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions CodeChef/#Aug20B_CHEFWARS.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@


def is_prime(num):
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
return all(num % i != 0 for i in range(2, int(math.sqrt(num)) + 1))


def input_list():
ll = list(map(int, input().split(" ")))
return ll
return list(map(int, input().split(" ")))


tc = int(input())
Expand Down
8 changes: 2 additions & 6 deletions CodeChef/#Aug20B_CRDGAME3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@


def is_prime(num):
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
return all(num % i != 0 for i in range(2, int(math.sqrt(num)) + 1))


def input_list():
ll = list(map(int, input().split(" ")))
return ll
return list(map(int, input().split(" ")))


tc = int(input())
Expand Down
8 changes: 2 additions & 6 deletions CodeChef/#Aug20B_LINCHESS.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@


def is_prime(num):
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
return all(num % i != 0 for i in range(2, int(math.sqrt(num)) + 1))


def input_list():
ll = list(map(int, input().split(" ")))
return ll
return list(map(int, input().split(" ")))


tc = int(input())
Expand Down
8 changes: 2 additions & 6 deletions CodeChef/#Aug20B_SKMP.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@


def is_prime(num):
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
return all(num % i != 0 for i in range(2, int(math.sqrt(num)) + 1))


def input_list():
ll = list(map(int, input().split(" ")))
return ll
return list(map(int, input().split(" ")))


tc = int(input())
Expand Down
8 changes: 2 additions & 6 deletions CodeChef/#COLE2020_CLLCM.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@


def is_prime(num):
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
return all(num % i != 0 for i in range(2, int(math.sqrt(num)) + 1))


def input_list():
lll = list(map(int, input().split(" ")))
return lll
return list(map(int, input().split(" ")))


tc = int(input())
Expand Down
27 changes: 9 additions & 18 deletions CodeChef/#July20B_ADAKING.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,32 @@


def is_prime(num):
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
return all(num % i != 0 for i in range(2, int(math.sqrt(num)) + 1))


def input_list():
ll = list(map(int, input().split(" ")))
return ll
return list(map(int, input().split(" ")))


def find_sum(x):
ss = 0
for i in x:
ss += int(i)
return ss
return sum(int(i) for i in x)


tc = int(input())
for _ in range(tc):
xy = int(input())
l = 1
arr = [["O", "X", "X", "X", "X", "X", "X", "X"]]
for i in range(7):
x = []
for j in range(8):
x.append("X")
for _ in range(7):
x = ["X" for _ in range(8)]
arr.append(x)

for i in range(len(arr)):
for item in arr:
if l == xy:
break
for j in range(len(arr[i])):
if arr[i][j] != "0" and l < xy:
arr[i][j] = "."
for j in range(len(item)):
if item[j] != "0" and l < xy:
item[j] = "."
l += 1
if l == xy:
break
Expand Down
12 changes: 3 additions & 9 deletions CodeChef/#July20B_CHEFSTR1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,16 @@


def is_prime(num):
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
return all(num % i != 0 for i in range(2, int(math.sqrt(num)) + 1))


def input_list():
ll = list(map(int, input().split(" ")))
return ll
return list(map(int, input().split(" ")))


tc = int(input())
for _ in range(tc):
n = int(input())
arr = input_list()
ans = 0
for i in range(1, n):
ans += abs(arr[i] - arr[i - 1]) - 1
ans = sum(abs(arr[i] - arr[i - 1]) - 1 for i in range(1, n))
print(ans)
12 changes: 4 additions & 8 deletions CodeChef/#July20B_CHFNSWPS.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,25 @@


def is_prime(num):
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
return all(num % i != 0 for i in range(2, int(math.sqrt(num)) + 1))


def input_list():
ll = list(map(int, input().split(" ")))
return ll
return list(map(int, input().split(" ")))


def def_value():
return 0


tc = int(input())
cc = 0
for _ in range(tc):
n = int(input())
a = input_list()
b = input_list()
zzz = 1000000000000
ans = 0
cc = 0
aa, bb, d = defaultdict(def_value), defaultdict(def_value), defaultdict(def_value)
xx, yy = [], []
zz = False
Expand Down Expand Up @@ -69,7 +65,7 @@ def def_value():
yy.append(b[i])
xx.sort()
yy.sort(reverse=True)
if len(xx) == 0:
if not xx:
print(0)
else:
for i in range(len(xx)):
Expand Down
13 changes: 3 additions & 10 deletions CodeChef/#July20B_CRDGAME.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@


def is_prime(num):
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
return all(num % i != 0 for i in range(2, int(math.sqrt(num)) + 1))


def input_list():
ll = list(map(int, input().split(" ")))
return ll
return list(map(int, input().split(" ")))


def find_sum(x):
ss = 0
for i in x:
ss += int(i)
return ss
return sum(int(i) for i in x)


tc = int(input())
Expand Down
14 changes: 3 additions & 11 deletions CodeChef/#July20B_CookOff_EVENTUAL.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@


def is_prime(num):
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
return all(num % i != 0 for i in range(2, int(math.sqrt(num)) + 1))


def input_list():
ll = list(map(int, input().split(" ")))
return ll
return list(map(int, input().split(" ")))


tc = int(input())
Expand All @@ -29,11 +25,7 @@ def input_list():
x[i] = 1
else:
x[i] += 1
c = False
for i, j in x.items():
if j % 2 != 0:
c = True
break
c = any(j % 2 != 0 for j in x.values())
if c:
print("NO")
else:
Expand Down
8 changes: 2 additions & 6 deletions CodeChef/#July20B_CookOff_ORTHODOX.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@


def is_prime(num):
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
return all(num % i != 0 for i in range(2, int(math.sqrt(num)) + 1))


def input_list():
ll = list(map(int, input().split(" ")))
return ll
return list(map(int, input().split(" ")))


tc = int(input())
Expand Down
10 changes: 3 additions & 7 deletions CodeChef/#July20B_PTMSSNG.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@


def is_prime(num):
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
return all(num % i != 0 for i in range(2, int(math.sqrt(num)) + 1))


def input_list():
ll = list(map(int, input().split(" ")))
return ll
return list(map(int, input().split(" ")))


tc = int(input())
Expand All @@ -23,7 +19,7 @@ def input_list():
v = (4 * n) - 1
v1, v2 = map(int, input().split())
xx, yy = v1, v2
for i in range(1, v):
for _ in range(1, v):
x, y = map(int, input().split())
xx = xx ^ x
yy = yy ^ y
Expand Down
19 changes: 4 additions & 15 deletions CodeChef/#June20_LTIME_CHFMOT18.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@


def is_prime(num):
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
return all(num % i != 0 for i in range(2, int(math.sqrt(num)) + 1))


def input_list():
ll = list(map(int, input().split(" ")))
return ll
return list(map(int, input().split(" ")))


tc = int(input())
Expand All @@ -25,19 +21,12 @@ def input_list():
if s % n == 0 and s >= n:
print(s // n)
elif s < n:
if s == 1:
print(1)
elif s % 2 == 0:
if s == 1 or s % 2 == 0:
print(1)
else:
print(2)
else:
l = s // n
x = s % n
if x == 1:
l += 1
elif x % 2 == 0:
l += 1
else:
l += 2
l += 1 if x == 1 or x % 2 == 0 else 2
print(l)
17 changes: 4 additions & 13 deletions CodeChef/#June20_LTIME_INCRDEC.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@


def is_prime(num):
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
return all(num % i != 0 for i in range(2, int(math.sqrt(num)) + 1))


def input_list():
ll = list(map(int, input().split(" ")))
return ll
return list(map(int, input().split(" ")))


tc = int(input())
Expand All @@ -24,8 +20,7 @@ def input_list():
n = int(input())
arr = input_list()
l = {}
x = list(set(arr))
x.sort()
x = sorted(set(arr))
fl = False
for i in arr:
if i not in l:
Expand All @@ -44,11 +39,7 @@ def input_list():
for i, j in l.items():
print(i, end=" ")
l[i] -= 1
ss = []
for i, j in l.items():
if j >= 1:
ss.append(i)

ss = [i for i, j in l.items() if j >= 1]
ss = ss[::-1]
for i in ss:
print(i, end=" ")
Expand Down
Loading

0 comments on commit ff704ca

Please sign in to comment.