Dashboard Temp Share Shortlinks Frames API

prakhardoneria - HTMLify profile

files of /prakhardoneria/geekstreak60/

/prakhardoneria/geekstreak60/30.py
33 Views
0 Comments
from collections import deque, defaultdict

class Solution:
def verticalOrder(self, root):
if not root:

The Painter's Partition Problem-II /prakhardoneria/geekstreak60/day1.py
52 Views
0 Comments
class Solution:
def minTime(self, arr, k):
# Helper function to check if a max_time limit is feasible
def is
Union of Arrays with Duplicates /prakhardoneria/geekstreak60/day10.py
51 Views
0 Comments
class Solution:
def findUnion(self, a, b):
res_set = set(a)
res_set.update(b)

return li
Longest Span in two Binary Arrays /prakhardoneria/geekstreak60/day11.py
30 Views
0 Comments
class Solution:
def equalSumSpan(self, a1, a2):
n = len(a1)
first_occurrence = {0: -1}

pref
Longest Subarray with Majority Greater than K /prakhardoneria/geekstreak60/day12.py
50 Views
0 Comments
class Solution:
def longestSubarray(self, arr, k):
n = len(arr)
prefix_sum = 0
first_occ = {}

Isomorphic Strings /prakhardoneria/geekstreak60/day13.py
47 Views
0 Comments
class Solution:
def areIsomorphic(self, s1, s2):
if len(s1) != len(s2):
return False

ma
Number of submatrix have sum X /prakhardoneria/geekstreak60/day14.py
40 Views
0 Comments
class Solution:
def countSquare(self, mat, x):
n = len(mat)
m = len(mat[0])

pref = [[0] * (
Find the closest pair from two arrays /prakhardoneria/geekstreak60/day15.py
45 Views
0 Comments
class Solution:
def findClosestPair(self, arr1, arr2, x):
n = len(arr1)
m = len(arr2)

# Ini
/prakhardoneria/geekstreak60/day16.py
28 Views
0 Comments
class Solution:
def pushZerosToEnd(self, arr):
count = 0 # Pointer for the position of the next non-zero element

Trapping Rain Water /prakhardoneria/geekstreak60/day17.py
30 Views
0 Comments
class Solution:
def maxWater(self, arr):
if not arr:
return 0

n = len(arr)

Longest subarray with Atmost two distinct integers /prakhardoneria/geekstreak60/day18.py
34 Views
0 Comments
class Solution:
def totalElements(self, arr):
left = 0
max_len = 0
freq = {}
distinct = 0

Max Xor Subarray of size K /prakhardoneria/geekstreak60/day19.py
25 Views
0 Comments
class Solution:
def maxSubarrayXOR(self, arr, k):
n = len(arr)
current_xor = 0

# 1. Calcula
Chocolate Distribution Problem /prakhardoneria/geekstreak60/day2.py
54 Views
0 Comments
class Solution:
def findMinDiff(self, arr, m):
if m == 0 or len(arr) == 0:
return 0

arr
Longest Substring with K Uniques /prakhardoneria/geekstreak60/day20.py
29 Views
0 Comments
class Solution:
def longestKSubstr(self, s, k):
n = len(s)
distinct_map = {}
left = 0
max_le
The Smallest Window Substring /prakhardoneria/geekstreak60/day21.py
20 Views
0 Comments
from collections import Counter

class Solution:
def minWindow(self, s, p):
if not s or not p:
return ""
Dice throw /prakhardoneria/geekstreak60/day22.py
29 Views
0 Comments
class Solution:
def noOfWays(self, m, n, x):
dp = [[0] * (x + 1) for _ in range(n + 1)]

dp[0][0] =
Pythagorean Triplet /prakhardoneria/geekstreak60/day23.py
35 Views
0 Comments
class Solution:
def pythagoreanTriplet(self, arr):
max_val = 0
for x in arr:
if x > max_val:

/prakhardoneria/geekstreak60/day24.py
29 Views
0 Comments
class Solution:
def largestSwap(self, s):
s_list = list(s)
n = len(s)

sorted_s = sorted(s_l
/prakhardoneria/geekstreak60/day27.py
33 Views
0 Comments
from collections import deque

class Solution:
def kBitFlips(self, arr, k):
n = len(arr)
flip_ends = deque()
/prakhardoneria/geekstreak60/day28.py
25 Views
0 Comments
class Solution:
def generateIp(self, s):
res = []
n = len(s)

if n < 4 or n > 12:

/prakhardoneria/geekstreak60/day29.py
20 Views
0 Comments
from collections import deque

class Solution:
def topView(self, root):
if not root:
return []

Meeting Rooms /prakhardoneria/geekstreak60/day3.py
50 Views
0 Comments
class Solution:
def canAttend(self, arr):
# 1. Sort the meetings based on start times
# If start times are e
/prakhardoneria/geekstreak60/day31.py
27 Views
0 Comments
class Solution:
def countAllPaths(self, root, k):
prefix_sums = {0: 1}

def dfs(node, current_sum):

/prakhardoneria/geekstreak60/day34.py
21 Views
0 Comments
class Solution:
def largestBst(self, root):
self.max_size = 0

def traverse(node):
if no
/prakhardoneria/geekstreak60/day35.py
17 Views
0 Comments
class Solution:
def findPreSuc(self, root, key):
pre = None
suc = None

# Finding Successor

/prakhardoneria/geekstreak60/day36.py
25 Views
0 Comments
import math

class Solution:
def countBSTs(self, arr):
n = len(arr)

def get_catalan(k):

/prakhardoneria/geekstreak60/day37.py
26 Views
0 Comments
from collections import deque

class Solution:
def orangesRot(self, mat):
rows = len(mat)
cols = len(mat[0])
Maximum number of overlapping Intervals /prakhardoneria/geekstreak60/day4.py
75 Views
0 Comments
class Solution:
def overlapInt(self, arr):
max_val = 0
for start, end in arr:
if end > max_val:

Count Inversions /prakhardoneria/geekstreak60/day5.py
66 Views
0 Comments
class Solution:
def inversionCount(self, arr):
def merge_and_count(temp_arr, left, mid, right):
i = left
Missing Element in Range /prakhardoneria/geekstreak60/day6.py
48 Views
0 Comments
class Solution:
def missingRange(self, arr, low, high):
present_elements = set()
for num in arr:

Form the Largest Number /prakhardoneria/geekstreak60/day7.py
61 Views
0 Comments
from functools import cmp_to_key

class Solution:
def findLargest(self, arr):
arr = list(map(str, arr))


Calculating the H-Index /prakhardoneria/geekstreak60/day8.py
55 Views
0 Comments
class Solution:
def hIndex(self, citations):
n = len(citations)
buckets = [0] * (n + 1)

for
Count Subarrays with given XOR /prakhardoneria/geekstreak60/day9.py
40 Views
0 Comments
class Solution:
def subarrayXor(self, arr, k):
res = 0
pref_xor = 0
counts = {0: 1}