0% found this document useful (0 votes)
22 views18 pages

Probs

The document lists various programming problems along with their expected inputs, outputs, difficulty levels, and brief descriptions. Each problem is assigned a unique identifier and categorized by its complexity, ranging from easy to hard. Examples of problems include 'Two Sum', 'Maximum Subarray', and 'Fizz Buzz', with corresponding test cases provided.

Uploaded by

mailajannu28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views18 pages

Probs

The document lists various programming problems along with their expected inputs, outputs, difficulty levels, and brief descriptions. Each problem is assigned a unique identifier and categorized by its complexity, ranging from easy to hard. Examples of problems include 'Two Sum', 'Maximum Subarray', and 'Fizz Buzz', with corresponding test cases provided.

Uploaded by

mailajannu28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 18

S.

Question Expected Difficulty Test cases


Description Expected Input
No. name Output Level
1

Given an array of integers


`nums` and an integer
`target`, return indices of the
Two Sum nums": [2, 7, 11, 15], Input: nums = [3, 3], target = 6
1 two numbers such that they [0, 1] easy
Problem "target": 9 Output: [0, 1]
add up to `target`. Assume
that there is exactly one
solution.

Given an integer array


`nums`, find the contiguous Input: nums = [0, -3, 1, 0, -1]
Maximum subarray (containing at least { "nums": [-2, 1, -3, 4, - Output: 1
2 6 easy
Subarray one number) which has the 1, 2, 1, -5, 4] },
largest sum and return its
sum.", "input_example": {

Determine whether an
Input: x = -121
integer `x` is a palindrome.
Palindrome Output: false
3 An integer is a palindrome { "x": 121 }, 1 easy
Number
when it reads the same
backward as forward

Given an integer `n`, return


a string array `answer`
where:\n- `answer[i]
== \"FizzBuzz\"` if `i` is
Input: n = 15
divisible by 3 and 5.\n-
["1", "2", Output: ["1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8",
`answer[i] == \"Fizz\"` if `i`
4 Fizz Buzz { "n": 5 }, "Fizz", "4", easy "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz"]
is divisible by 3.\n-
"Buzz"]
`answer[i] == \"Buzz\"` if
`i` is divisible by 5.\n-
`answer[i] == i` (as a string)
if none of the above
conditions
You are givenare true.
the heads of
two sorted linked lists `list1` Input: list1 = [], list2 = [1, 3, 4]
Merge Two and `list2`. Merge the two list1": [1, 2, 4], "list2": [1, 1, 2, 3, Output: [1, 3, 4]
5 easy
Sorted Lists lists in a sorted manner and [1, 3, 4] 4, 4]
return the head of the new
list.
Given a string `s` containing
just the characters '(', ')', '{',
'}', '[' and ']', determine if the
input string is valid. An Input: s = "([{}])"
Valid input string is valid if:\n1. Output: true
6 { "s": "()[]{}" }, 1 easy
Parentheses Open brackets must be
closed by the same type of
brackets.\n2. Open brackets
must be closed in the correct
order

Given a signed 32-bit


integer `x`, return `x` with
Input: x = -123
its digits reversed. If
Reverse Output: -321
7 reversing `x` causes the "x": 123 }, 321 easy
Integer
value to go outside the
signed 32-bit integer range,
return 0.

You are climbing a


staircase. It takes `n` steps
Input: n = 4
to reach the top. Each time
Climbing Output: 5
8 you can either climb 1 or 2 { "n": 3 }, 3 easy
Stairs
steps. In how many distinct
ways can you climb to the
top?

Input: [2, 4, 6, 8]
Find the maximum sum of
Not Even Output: 20
9 even numbers in a given [1, 2, 3, 4, 5, 6] 12 easy
Max Sum
array.

Input: [0, 1, 2, 3, 4, 5], 5


Find all unique pairs of
[[1, 4], [2, Output: [[0, 5], [1, 4], [2, 3]]
10 Find Pairs numbers in an array that [1, 2, 3, 4, 5], 5" easy
3]]
sum up to a given target.
Input: [1, 1, 1, 1, 1], 0, 4
Count the number of cloudy
Output: 5
11 Cloudy Days days in a given range of [0, 1, 1, 0, 1], 1, 3 2 easy
weather data.

Input:[1, 2, 3], [[0, 1], [1, 2]]


Range Answer multiple range sum [1, 2, 3, 4, 5], [[0, 2], Output: [3, 5]
12 [6, 9] easy
Queries queries on an array [1, 3]]

Input: [1, 1, 1], [2, 2, 2]


Maximize the sum of two
Output: 9
13 Swap Sum arrays by swapping [1, 2, 3], [4, 5, 6] 21 easy
elements between them.

Input: [7, 14, 21], 7


Calculate the minimum
Killer Output: 6
14 number of attacks needed to [10, 20, 30], 10 6 easy
Monsters
defeat all monsters

Input: education
Count Vowels Vowels: 2,
Count the number of vowels Output: Vowels: 5, Consonants: 4
15 and hello Consonants: easy
and consonants in a string.
Consonants 3

Input: [[1, 10]], [2, 3]


Remove Remove a specific interval [[1, 2], [8, Output: [[1, 2], [3, 10]]
16 [[1, 5], [6, 10]], [2, 8] medium
Interval from a set of intervals 10]]
Input: {1: [(2, 2), (3, 1)], 2: [(3, 2)], 3: []}, 1, 3
Find the shortest path in a
Path with {1: [(2, 3)], 2: [(3, 1)], Output: 3
17 graph considering weighted 4 medium
hyperloops 3: []}, 1, 3"
edges and hyperloops.

Divide an array into two Input: [7, 3, 2, 9]


Optimal parts such that the [[1, 2, 3], Output: [[7, 9], [3, 2]]
18 [1, 2, 3, 4, 5] medium
Division difference between their [4, 5]]
sums is minimized.

Input: [[1, 0], [0, 1]]


Find the minimum number
Turn Off Output: 2
19 of steps to turn off all the [[1, 1], [1, 0]] 3 medium
Lights
lights in a grid.

Input: [[0, 0, 0], [0, 1, 0], [0, 0, 0]]Output: [[1, 1, 1],


Replace specific zero
Zeropocalyps [[1, 1], [1, [1, 1, 1], [1, 1, 1]]
20 elements in a matrix [[1, 0], [0, 1]] medium
e 1]]
according to the given rules.

Input: [2, 3, 5, 7]
Calculate the sum of the
Consecutive Output: 76
21 products of all consecutive [1, 2, 3, 4] 20 medium Input: [['T', '.', 'T'], ['.', 'X', '.'], ['T', '.', '.']] Output: 6
Product Sum Help Bob collect all [['.', 'T', '.'], ['X', '.', 'T'],
22 Bob's Quest elements
treasures in aangrid
array.
while 4 medium
['.', '.', '.']]
avoiding obstacles
Input: 'abcde', ['L1', 'R4']
Scroll-a- Perform a series of scroll Output: 'bcdea'
23 'hello', ['R1', 'L2', 'R3'] 'llohe' medium
palooza operations on a string

Input: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] Output:


Rotate a 2D matrix 90 [[3, 1], [4, [[7, 4, 1], [8, 5, 2], [9, 6, 3]]
24 Rotate Matrix [[1, 2], [3, 4]] medium
degrees clockwise 2]]

Input: [1, 1, 2, 3, 4, 4, 5]
Find
Find all duplicates in an Output: [1, 4]
25 Duplicates in [4, 3, 2, 7, 8, 2, 3, 1] [2, 3] medium
integer array
an Array

Input: 1, 5
MystiXORam Calculate the XOR of all Output: 1
26 2, 6 0 hard
a numbers in a given range
Input: {1: [2, 3, 4], 2: [], 3: [5, 6], 4: [], 5: [], 6: []}, 3
Count the number of
Tree Subtree subtrees in a given tree that {1: [2, 3], 2: [4, 5], 3:
27 3 hard Output: 2
Divisibility satisfy specific divisibility [], 4: [], 5: []}, 2
conditions

Input: [0, 1, 1], [2, 3, 4]


Perform a specific bitwise
BitwiseBaffle Output: 6
28 operation on two arrays and [1, 2, 3], [4, 5, 6] 7 hard
ment
compute the result

Determine the minimum Input: {1: [2], 2: [3], 3: []}


Tree number of inversions {1: [2, 3], 2: [4], 3: [], Output: 1
29 2 hard
Inversions required to meet certain tree 4: []}
conditions.

Input: 1, 50
Lucky Count the number of 'lucky Output: 10
30 1, 100 20 hard
Numbers numbers' in a given range
Test cases
Python Code
2 3

def two_sum(nums, target): def two_sum(nums, target):


num_to_index = {} num_to_index = {}
Input: nums = [2, 7, 11, 15], target = 9
Input: nums = [5, 75, 25], target = 100 for i, num in enumerate(nums): for i, num in enumerate(nu
Output: [0, 1]
Output: [1, 2] complement = target - num complement = target - nu
if complement in num_to_index: if complement in num_t
return [num_to_index[complement], i] return [num_to_index
num_to_index[num] = i num_to_index[num] = i

def max_subarray(nums): def max_subarray(nums):


Input: [10, -1, 2, -1, 5] Input: [1, 2, -3, 4, -1, 2] max_sum = current_sum = nums[0] max_sum = current_sum =
Output: 15 Output: 6 for num in nums[1:]: for num in nums[1:]:
current_sum = max(num, current_sum + num) current_sum = max(num
max_sum = max(max_sum, current_sum) max_sum = max(max_su
return max_sum return max_sum

Input: 1 Input: 22222 def is_palindrome(x): def is_palindrome(x):


Output: true Output: true if x < 0: if x < 0:
return False return False
return str(x) == str(x)[::-1] return str(x) == str(x)[::-1]

def fizz_buzz(n):
result = []
for i in range(1, n + 1):
Input: 20
if i % 3 == 0 and i % 5 == 0:
Output: ["1", "2", "Fizz", "4", "Buzz", "Fizz",
Input: 7 result.append("FizzBuzz")
"7", "8", "Fizz", "Buzz", "11", "Fizz", "13", class elif
ListNode: def fizz_buzz(n):
Output: ["1", "2", "Fizz", "4", "Buzz", "Fizz", "7"] i % 3 == 0:
"14", "FizzBuzz", "16", "17", "Fizz", "19", def __init__(self, val=0, next=None): return ["FizzBuzz" if i % 1
result.append("Fizz")
"Buzz"] self.val "Buzz" if i % 5 == 0 else str(i
elif i % = val 0:
5 ==
self.next = next
result.append("Buzz") def merge_two_lists(list1, list
else: merged = []
def merge_two_lists(list1,
result.append(str(i))list2): i=j=0
dummy = ListNode()
return result while i < len(list1) and j <
current = dummy if list1[i] < list2[j]:
Input: list1 = [0, 1], list2 = [2, 3, 4] Input: list1 = [1, 4], list2 = [3, 5, 7]
while list1 and list2: merged.append(list1[i
Output: [0, 1, 2, 3, 4] Output: [1, 3, 4, 5, 7]
if list1.val < list2.val: i += 1
current.next = list1 else:
list1 = list1.next merged.append(list2[j
else: j += 1
current.next = list2 merged.extend(list1[i:])
list2 = list2.next merged.extend(list2[j:])
def is_valid(s): def is_valid_parentheses(s):
stack = [] stack = []
mapping = {')': '(', '}': '{', ']': '['} mapping = {')': '(', '}': '{', ']
for char in s: for char in s:
Input: "()" Input: "]("
if char in mapping: if char in mapping:
Output: true Output: false
top = stack.pop() if stack else '#' top_element = stack.p
if mapping[char] != top: if mapping[char] != to
return False return False
else: else:
stack.append(char) stack.append(char)
return not stack return not stack

def reverse_integer(x):
sign = -1 if x < 0 else 1 def reverse_integer(x):
Input: 1001
Input: 4567 x = abs(x) sign = -1 if x < 0 else 1
Output: 1001
Output: 7654 reversed_num = int(str(x)[::-1]) reversed_x = int(str(abs(x)
if reversed_num > 2**31 - 1: return sign * reversed_x if
return 0 1 else 0
return sign * reversed_num

def climb_stairs(n): def climbing_stairs(n):


if n == 1: if n <= 2:
Input: n = 8 nput: n = 15
return 1 return n
Output: 34 Output: 987
a, b = 1, 2 a, b = 1, 2
for _ in range(3, n + 1): for _ in range(3, n + 1):
a, b = b, a + b a, b = b, a + b
return b return b

Input: [5, 10, 15] Input: [10, 15, 25, 30, 40] Output:
def max_sum_not_even(num
Output: 30 90 def max_even_sum(nums):
nums = [num for num in nu
return sum(num for num in nums if num % 2 == 0)
return sum(nums)

def find_pairs(nums, k):


def find_pairs(nums, target):
nums.sort()
seen = set()
seen = set()
pairs = []
pairs = set()
Input: [5, 5, 5, 5], 10 for num in nums:
Input: [5, 10, 15], 20 for num in nums:
Output: [[5, 5], [5, 5]] complement = target - num
Output: [[5, 15]] if num - k in seen:
if complement in seen:
pairs.add((num - k, nu
pairs.append([min(num, complement), max(num,
if num + k in seen:
complement)])
pairs.add((num, num +
seen.add(num)
seen.add(num)
return pairs
return len(pairs)
Input: [0, 0, 0, 0, 0], 0, 4 Input: [1, 0, 1, 0, 1, 1], 0, 5
Output: 0 Output: 3 def count_cloudy_days(weather, start, end): def cloudy_days(days):
return sum(1 for i in range(start, end + 1) if weather[i] == 1) return [day for day in days

def range_sum_queries(nums, queries):


nput: [8, 2, 4, 7], [[0, 2], [1, 3]] Input: [5, 4, 3, 2, 1], [[0, 4], [1, 3]] prefix_sum = [0] * (len(nums) + 1)
Output: [14, 13] Output: [15, 9] for i in range(len(nums)): def range_sum_query(nums,
prefix_sum[i + 1] = prefix_sum[i] + nums[i] return [sum(nums[start:end
return [prefix_sum[end + 1] - prefix_sum[start] for start, end in
queries]

Input: [7, 8, 9], [10, 11, 12] Input: [5, 6, 7], [1, 2, 3]
def maximize_sum(arr1, arr2):
Output: 150 Output: 21 def swap_sum(arr1, arr2):
combined = sorted(arr1 + arr2, reverse=True)
return sum(arr2) - sum(arr1
return sum(combined[:len(arr1)])

Input: [15, 25, 35], 10 Input: [10, 10, 10], 5


Output: 7 Output: 6 def min_attacks(hp, attack): def killer_monsters(monsters
return sum((h + attack - 1) // attack for h in hp) return [monster for monste

def count_vowels_and_consonants(s):
def count_vowels_and_conso
Input: "ChatGPT" Input: "This is a test" vowels = "aeiouAEIOU"
vowels = set('aeiouAEIOU
Output: Vowels: 1, Consonants: 6 Output: Vowels: 4, Consonants: 7 v_count = sum(1 for char in s if char in vowels)
v_count = sum(1 for char i
c_count = sum(1 for char in s if char.isalpha() and char not in
c_count = sum(1 for char i
vowels)
return v_count, c_count
return f"Vowels: {v_count}, Consonants: {c_count}"

def remove_interval(intervals, to_remove): def remove_interval(intervals


result = [] result = []
for start, end in intervals: for start, end in intervals:
if end <= to_remove[0] or start >= to_remove[1]: if end <= to_remove[0] o
Input: [[1, 3], [4, 6]], [2, 5] Input: [[1, 3], [4, 5], [6, 8]], [2, 7]
result.append([start, end]) result.append((start, e
Output: [[1, 2], [5, 6]] Output: [[1, 2], [7, 8]]
else: else:
if start < to_remove[0]: if start < to_remove[0
result.append([start, to_remove[0]]) result.append((start
if end > to_remove[1]: if end > to_remove[1]
result.append([to_remove[1], end]) result.append((to_r
return result return result
import heapq

def shortest_path(graph, start, end):


pq = [(0, start)]
visited = {}
Input: {1: [(2, 5)], 2: [(3, 2)], 3: []}, 1, 3 while pq:
def hyperloop_path(paths, hy
Input: {1: [(2, 2), (3, 1)], 2: [(3, 2)], 3: []}, 1, 3 Output: 7 cost, node = heapq.heappop(pq)
total = sum(paths)
Output: 4 if node in visited:
discount = sum(min(hyperl
continue
hyperloops))
visited[node] = cost
return total - discount
if node == end:
return cost
for neighbor, weight in graph.get(node, []):
if neighbor not in visited:
heapq.heappush(pq, (cost + weight, neighbor))
return -1

def optimal_division(nums):
def minimize_difference(nums):
Input: [1, 3, 5, 7] Input: [100, 50, 25, 10] if len(nums) == 1:
nums.sort()
Output: [[1, 3], [5, 7]] Output: [[100], [50, 25, 10]] return str(nums[0])
half = len(nums) // 2
if len(nums) == 2:
return [nums[:half], nums[half:]]
return f"{nums[0]}/{num
return f"{nums[0]}/({'/'.joi
Input: [[0, 0], [1, 1]] Input: [[1, 0], [1, 1]]
Output: 2 Output: 3 def min_steps_to_turn_off_lights(grid): def turn_off_lights(lights):
def zeropocalypse(matrix):
return sum(sum(row) for row in grid) return [i for i, light in enum
rows, cols = len(matrix), le
zero_rows, zero_cols = set
def replace_zeros(matrix): for i in range(rows):
rows, cols = len(matrix), len(matrix[0]) for j in range(cols):
Input: [[1, 0, 0], [1, 1, 0]] Input: [[0, 0], [0, 0]]
for r in range(rows): if matrix[i][j] == 0:
Output: [[1, 1, 1], [1, 1, 1]] Output: [[1, 1], [1, 1]]
for c in range(cols): zero_rows.add(i)
if matrix[r][c] == 0: zero_cols.add(j)
matrix[r][c] = 1 for i in range(rows):
return matrix for j in range(cols):
def collect_treasures(grid): if i in zero_rows or j i
Input: [1, 2, 3] Input: [2, 3, 4, 5] rows, cols = len(grid), len(grid[0])
Input: matrix[i][j] = 0
Output:[["X",
20 ".", ".", "."], [".", "X", ".", "."], ["T", ".", Input:
Output:[[".",
54 ".", "."], [".", "X", "."], ["T", ".", deftreasures
consecutive_product_sum(nums):
=0 def consecutive_product_sum
".", "."]] "."]] return matrix
return
for rowsum(nums[i]
in grid: * nums[i + 1] for i in range(len(nums) - 1)) defreturn sum(nums[i] * nums
bobs_quest(steps):
Output: 4 Output: 2
for cell in row: return sum(abs(step) for ste
if cell == 'T':
treasures += 1
return treasures
def scroll_string(s, operations):
s = list(s)
for op in operations:
Input: 'flip', ['R1', 'L2'] Input: 'python', ['R1', 'L3'] direction, steps = op[0], int(op[1:])
Output: 'lipf' Output: 'honpyt' steps %= len(s) def scroll_palooza(scrolls):
if direction == 'R': return sum(len(scroll) for s
s = s[-steps:] + s[:-steps]
elif direction == 'L':
s = s[steps:] + s[:steps]
return ''.join(s)

Input: Input:
[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] [[1, 2, 3, 4]]
def rotate_matrix(matrix):
Output: Output: def rotate_matrix(matrix):
matrix[:] = zip(*matrix[::-1])
[[9, 7, 5, 3, 1], [10, 8, 6, 4, 2]] [[4], [3], [2], [1]] return list(zip(*matrix[::-1]
return matrix

def find_duplicates(nums):
def find_duplicates(nums):
seen = set()
Input: Input: result = []
duplicates = set()
[1, 1, 1, 1] [0, 1, 1, 2, 2, 3, 4] for num in nums:
for num in nums:
Output: [1] Output: if nums[abs(num) - 1] < 0:
if num in seen:
[1, 2] result.append(abs(num))
duplicates.add(num)
else:
else:
nums[abs(num) - 1] *= -1
seen.add(num)
return result
def range_xor(start, end): return list(duplicates)
def xor_upto(x):
if x % 4 == 0:
return x def mystixorama(nums):
Input: 0, 8
Input: 4, 9 Output: 12 elif x % 4 == 1: result = 0
Output: 8
return 1 for num in nums:
elif x % 4 == 2: result ^= num
return x + 1 return result
else:
return 0
return xor_upto(end) ^ xor_upto(start - 1)
def count_divisible_subtrees(tree, divisor):
count = 0
def dfs(node):
nonlocal count
if not tree[node]:
Input: {1: [2], 2: [3, 4], 3: [], 4: []}, 3 Input: {1: [2, 3, 4], 2: [], 3: [], 4: []}, 1 return 1
Output: 1 Output: 3 subtree_size = 1 def subtree_divisibility(tree, d
for child in tree[node]: return all(value % divisor =
subtree_size += dfs(child)
if subtree_size % divisor == 0:
count += 1
return subtree_size
dfs(1)
return count
Input: [7, 6], [3, 4] Input: [10, 20, 30], [5, 15, 25]
Output: 7 Output: 27 def bitwise_bafflement(arr1, arr2): def bitwise_bafflement(nums
return sum(a ^ b for a, b in zip(arr1, arr2)) return sum(a & b for a, b in

def min_tree_inversions(tree):
def dfs(node):
Input: {1: [2, 3], 2: [], 3: []}, 3 Input: {1: [2, 3], 2: [4], 3: [], 4: []}, 4
inversions = 0 def tree_inversions(tree):
Output: 0 Output: 1
for child in tree[node]: return sum(1 for i in range(
inversions += dfs(child) tree[i] > tree[j])
return inversions + (1 if len(tree[node]) > 1 else 0)
return dfs(1)

Input: 1000, 1200 Input: 100, 150


def lucky_numbers(nums):
Output: 33 Output: 10 def count_lucky_numbers(start, end):
return [num for num in num
return sum(1 for i in range(start, end + 1) if '7' in str(i))
7 == 0]
Optimal code Execution time

wo_sum(nums, target):
m_to_index = {}
i, num in enumerate(nums):
complement = target - num 0.000058 seconds
f complement in num_to_index:
return [num_to_index[complement], i]
num_to_index[num] = i

ax_subarray(nums):
x_sum = current_sum = nums[0]
num in nums[1:]:
0.000062 seconds
current_sum = max(num, current_sum + num)
max_sum = max(max_sum, current_sum)
urn max_sum

_palindrome(x):
< 0:
0.000053 seconds
eturn False
urn str(x) == str(x)[::-1]

zz_buzz(n):
urn ["FizzBuzz" if i % 15 == 0 else "Fizz" if i % 3 == 0 else 0.000063 seconds
z" if i % 5 == 0 else str(i) for i in range(1, n + 1)]
erge_two_lists(list1, list2):
rged = []
j=0
ile i < len(list1) and j < len(list2):
f list1[i] < list2[j]:
merged.append(list1[i])
i += 1 0.000084 seconds
else:
merged.append(list2[j])
j += 1
rged.extend(list1[i:])
rged.extend(list2[j:])
_valid_parentheses(s):
ck = []
pping = {')': '(', '}': '{', ']': '['}
char in s:
f char in mapping:
top_element = stack.pop() if stack else '#' 0.000051 seconds
if mapping[char] != top_element:
return False
else:
stack.append(char)
urn not stack

verse_integer(x):
n = -1 if x < 0 else 1
ersed_x = int(str(abs(x))[::-1]) 0.000043 seconds
urn sign * reversed_x if -(2**31) <= sign * reversed_x <= 2**31 -
0

imbing_stairs(n):
<= 2:
eturn n
b = 1, 2 0.0000198 seconds
_ in range(3, n + 1):
a, b = b, a + b
urn b

ax_sum_not_even(nums):
ms = [num for num in nums if num % 2 != 0] 0.000060 seconds
urn sum(nums)

nd_pairs(nums, k):
ms.sort()
n = set()
rs = set()
num in nums:
f num - k in seen: 0.000063 seconds
pairs.add((num - k, num))
f num + k in seen:
pairs.add((num, num + k))
seen.add(num)
urn len(pairs)
oudy_days(days):
0.000088 seconds
urn [day for day in days if day < 0]

nge_sum_query(nums, queries):
0.000086 seconds
urn [sum(nums[start:end+1]) for start, end in queries]

wap_sum(arr1, arr2):
0.000068 seconds
urn sum(arr2) - sum(arr1)

ller_monsters(monsters, power):
0.000060 seconds
urn [monster for monster in monsters if monster <= power]

ount_vowels_and_consonants(s):
wels = set('aeiouAEIOU')
count = sum(1 for char in s if char in vowels) 0.0000114 seconds
count = sum(1 for char in s if char.isalpha() and char not in vowels)
urn v_count, c_count

move_interval(intervals, to_remove):
ult = []
start, end in intervals:
f end <= to_remove[0] or start >= to_remove[1]:
result.append((start, end))
else: 0.00005 seconds
if start < to_remove[0]:
result.append((start, to_remove[0]))
if end > to_remove[1]:
result.append((to_remove[1], end))
urn result
yperloop_path(paths, hyperloops):
al = sum(paths)
count = sum(min(hyperloop, path) for path, hyperloop in zip(paths, 0.00004 seconds
loops))
urn total - discount

ptimal_division(nums):
en(nums) == 1:
eturn str(nums[0])
0.00003 seconds
en(nums) == 2:
eturn f"{nums[0]}/{nums[1]}"
urn f"{nums[0]}/({'/'.join(map(str, nums[1:]))})"

rn_off_lights(lights):
eropocalypse(matrix): 0.00002 seconds
urn [i for i, light in enumerate(lights) if light == 0]
ws, cols = len(matrix), len(matrix[0])
o_rows, zero_cols = set(), set()
i in range(rows):
or j in range(cols):
if matrix[i][j] == 0:
zero_rows.add(i) 0.00009 seconds
zero_cols.add(j)
i in range(rows):
or j in range(cols):
if i in zero_rows or j in zero_cols:
matrix[i][j] = 0
onsecutive_product_sum(nums):
urn matrix 0.00006 seconds
urn sum(nums[i] * nums[i + 1] for i in range(len(nums) - 1))
obs_quest(steps):
0.00003 seconds
urn sum(abs(step) for step in steps)
roll_palooza(scrolls):
0.00007 seconds
urn sum(len(scroll) for scroll in scrolls if scroll.isdigit())

tate_matrix(matrix):
0.00004 seconds
urn list(zip(*matrix[::-1]))

nd_duplicates(nums):
n = set()
plicates = set()
num in nums:
f num in seen: 0.00005 seconds
duplicates.add(num)
else:
seen.add(num)
urn list(duplicates)

ystixorama(nums):
ult = 0
num in nums: 0.00004 seconds
esult ^= num
urn result
ubtree_divisibility(tree, divisor):
0.00003 seconds
urn all(value % divisor == 0 for value in tree)

twise_bafflement(nums):
0.00006 seconds
urn sum(a & b for a, b in zip(nums, nums[1:]))

ee_inversions(tree):
urn sum(1 for i in range(len(tree)) for j in range(i + 1, len(tree)) if 0.00005 seconds
] > tree[j])

cky_numbers(nums):
urn [num for num in nums if sum(int(digit) for digit in str(num)) % 0.00004 seconds
0]

You might also like