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
def how_much_does_daytona_costs():
n, k = map(int, input().split())
a = list(map(int, input().split()))
if k in a:
return "YES"
return "NO"
t = int(input())
""" O(n*n) approach """
class Solution:
def pairWithMaxSum(self, arr):
# Your code goes here
nums = arr
globalMaxSum = float('-inf')
n = len(nums)
for i in range(n-1):
fMin = nums[i]
int go(int[] a, int l, int r) {
if (l == r)
return a[l];
int mid = (l + r) / 2;
return go(a, l, mid) + go(a, mid + 1, r);
}
int[] a = {...};
int N = a.length;
class Solution:
#User function Template for python3
#Complete this function
def findFloor(self,A,N,X):
#Your code here
nums = A
x = X
n = N
@AashishNandakumar
AashishNandakumar / 1873_target_practice.py
Last active August 30, 2024 05:58
August 30th 2024 Questions
def target_practice():
# hardcode the target matrix since it is always 10 * 10 matrix with fixed values
target = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 2, 2, 2, 2, 2, 2, 2, 2, 1],
[1, 2, 3, 3, 3, 3, 3, 3, 2, 1],
[1, 2, 3, 4, 4, 4, 4, 3, 2, 1],
[1, 2, 3, 4, 5, 5, 4, 3, 2, 1],
[1, 2, 3, 4, 5, 5, 4, 3, 2, 1],
[1, 2, 3, 4, 4, 4, 4, 3, 2, 1],
@AashishNandakumar
AashishNandakumar / 1862_sequence_game.py
Last active August 31, 2024 16:54
August 31st 2024 Questions
def sequence_game():
n = int(input())
b = list(map(int, input().split()))
res = [b[0]]
for i in range(1, n):
if b[i] < b[i - 1]:
res.append(1)
res.append(b[i])
@AashishNandakumar
AashishNandakumar / 1251_average_selling_price.sql
Created September 1, 2024 08:10
September 1st 2024 Questions
# Write your MySQL query statement below
select p.product_id, ifnull(round(sum(p.price * u.units) / sum(u.units), 2), 0) as average_price
from Prices p left join UnitsSold u on p.product_id=u.product_id and u.purchase_date between p.start_date and p.end_date
group by p.product_id;
@AashishNandakumar
AashishNandakumar / 1858_buttons.py
Created September 2, 2024 09:53
September 2nd 2024 Questions
def buttons():
a, b, c = map(int, input().split())
if c % 2 == 0:
if b >= a:
return "Second"
return "First"
else:
if a >= b:
return "First"
return "Second"
@AashishNandakumar
AashishNandakumar / 1472_long_jumps_brute_force.py
Last active September 4, 2024 12:40
September 3rd 2024 questions
def long_jumps():
# input
n = int(input())
a = list(map(int, input().split()))
# logic
globalMaxScore = float("-inf")
ptr = 0
while ptr < n:
@AashishNandakumar
AashishNandakumar / 1055_metro.py
Created September 4, 2024 17:31
September 4th 2024 Questions
# input
n, s = map(int, input().split())
a = [0] + list(map(int, input().split())) + [0]
b = [0] + list(map(int, input().split())) + [0]
# logic
reachable = False
for i in range(1, n + 1):
if i == 1 and a[i] == 0:
print("NO")