Skip to content

Instantly share code, notes, and snippets.

View AashishNandakumar's full-sized avatar
:shipit:
Developing...

Aashish Nandakumar AashishNandakumar

:shipit:
Developing...
View GitHub Profile
#User function Template for python3
from collections import deque
class Solution:
def addBinary(self, A, B):
# code here
len1 = len(A)
len2 = len(B)
carry = 0
# Holloumi Boxes
# logic
def can_sort_it(a, n, k) -> bool:
# def reverse(a, ptr1, ptr2):
# a[ptr1:ptr2] = reversed(a[ptr1:ptr2])
# if n == 1:
# return True
# logic
def can_take_the_trip() -> int:
"""
logic:
calculate gaps between each petrol stations, the max gap is the minimum fuel(1unit = 1lt) needed to complete the trip
"""
n, x = map(int, input().split())
petrol_stations = list(map(int, input().split()))
# approach 1
# Cover in Water
import re
def cover_in_water():
n = int(input())
s = input()
# logic here
def game_with_integer() -> str:
n = int(input())
if n % 3 == 0:
return "Second"
else:
return "First"
t = int(input())
for _ in range(t):
class Solution:
def isHappy(self, n: int) -> bool:
def get_sum_of_squares_of_digits(n) -> int:
res = 0
while n != 0:
res += (n % 10) ** 2
n //= 10
return res
visited = set()
class Solution:
def containsNearbyDuplicate(self, nums: List[int], k: int) -> bool:
n = len(nums)
# approach-1: brute force
# for i in range(n-1):
# for j in range(i+1, n):
# if abs(i-j) <= k and nums[i] == nums[j]:
# return True
def jagged_swaps():
n = int(input())
a = list(map(int, input().split()))
if a[0] == 1:
return "YES"
return "NO"
"""Actual sorting logic if a[0] == 1"""
# upper_bound = n
def doremys_paint():
n = int(input())
a = list(map(int, input().split()))
# logic here
"""
case1: if there is only 1 unique element, return 'YES'
case2: if there is 2 unique elements, and if any one element's count/frequency == n/2,
return 'YES' or 'NO' otherwise
case 3: if there is more than 2 unique elements return 'NO'
def dont_try_to_count():
n, m = map(int, input().split())
x = input()
s = input()
"""Approach 1"""
# operations = 0
# while len(x) <= n * m:
# if s in x:
# return operations