Dashboard Temp Share Shortlinks Frames API

prakhardoneria - HTMLify profile

files of /prakhardoneria/GFG/

Count Subset With Target Sum II.py /prakhardoneria/GFG/Count Subset With Target Sum II
36 Views
0 Comments
class Solution:
def countSubset(self, arr, k):
n = len(arr)
mid = n // 2
left = arr[:mid]
ri
Equalize the Towers.py /prakhardoneria/GFG/Equalize the Towers.py
14 Views
0 Comments
class Solution:
def minCost(self, heights, cost):
def get_cost(target_h):
total = 0
for h, c
Find Kth Rotation.py /prakhardoneria/GFG/Find Kth Rotation.py
12 Views
0 Comments
class Solution:
def findKRotation(self, arr):
low = 0
high = len(arr) - 1
n = len(arr)


Generate Permutations of an array.py /prakhardoneria/GFG/Generate Permutations of an array.py
29 Views
0 Comments
class Solution:
def permuteDist(self, arr):
res = []
self.solve(0, arr, res)
return res

def
Happiest Triplet.py /prakhardoneria/GFG/Happiest Triplet.py
35 Views
0 Comments
class Solution:
def smallestDiff(self, a, b, c):
a.sort()
b.sort()
c.sort()

i, j, k
Interleave the First Half of the Queue with Second Half.py /prakhardoneria/GFG/Interleave the First Half of the Queue with Second Half.py
42 Views
0 Comments
from collections import deque

class Solution:
def rearrangeQueue(self, q):
n = len(q)
half = n // 2

K Sized Subarray Maximum.py /prakhardoneria/GFG/K Sized Subarray Maximum.py
28 Views
0 Comments
from collections import deque

class Solution:
def maxOfSubarrays(self, arr, k):
n = len(arr)
dq = deque()

Koko Eating Bananas.py /prakhardoneria/GFG/Koko Eating Bananas.py
15 Views
0 Comments
import math

class Solution:
def kokoEat(self, arr, k):
# The minimum possible speed is 1
# The maximum spee
Last Moment Before All Ants Fall Out.py /prakhardoneria/GFG/Last Moment Before All Ants Fall Out.py
23 Views
0 Comments
class Solution:
def getLastMoment(self, n, left, right):
max_time = 0

if left:
max_time
Max Circular Subarray Sum.py /prakhardoneria/GFG/Max Circular Subarray Sum.py
26 Views
0 Comments
class Solution:
def maxCircularSum(self, arr):
total_sum = 0
curr_max = 0
max_so_far = arr[0]

Max sum in the configuration.py /prakhardoneria/GFG/Max sum in the configuration,py
28 Views
0 Comments
class Solution:
def maxSum(self, arr):
n = len(arr)
total_sum = sum(arr)
current_val = sum(i * arr[i
Maximize Number of 1's.py /prakhardoneria/GFG/Maximize Number of 1's.py
29 Views
0 Comments
class Solution:
def maxOnes(self, arr, k):
left = 0
max_len = 0
zero_count = 0

for
Maximum Product Subarray.py /prakhardoneria/GFG/Maximum Product Subarray.py
18 Views
0 Comments
class Solution:
def maxProduct(self, arr):
if not arr:
return 0

res = max(arr)

Number of Valid Parentheses.py /prakhardoneria/GFG/Number of Valid Parentheses.py
32 Views
0 Comments
import math

class Solution:
def findWays(self, n):
if n % 2 != 0:
return 0

k = n // 2
Stock Buy and Sell – Max one Transaction Allowed.py /prakhardoneria/GFG/Stock Buy and Sell – Max one Transaction Allowed.py
25 Views
0 Comments
class Solution:
def maxProfit(self, prices):
if not prices:
return 0

min_price = fl
Stream First Non-repeating.py /prakhardoneria/GFG/Stream First Non-repeating.py
28 Views
0 Comments
from collections import deque

class Solution:
def firstNonRepeating(self, s):
char_count = [0] * 26
queue =
Word Search.py /prakhardoneria/GFG/Word Search.py
33 Views
0 Comments
class Solution:
def isWordExist(self, mat, word):
n = len(mat)
m = len(mat[0])

def backtrac
candy.py /prakhardoneria/GFG/candy.py
39 Views
0 Comments
class Solution:
def minCandy(self, arr):
n = len(arr)
if n == 0:
return 0

# Ste
count-distinct-elements-in-every-window.py /prakhardoneria/GFG/count-distinct-elements-in-every-window.py
51 Views
0 Comments
class Solution:
def countDistinct(self, arr, k):
n = len(arr)
res = []
freq_map = {}


count-number-of-substrings.py /prakhardoneria/GFG/count-number-of-substrings.py
45 Views
0 Comments
class Solution:
def countSubstr(self, s, k):
def atMost(k):
freq = {}
left = 0
r
count-subarray-with-k-odds.py /prakhardoneria/GFG/count-subarray-with-k-odds.py
36 Views
0 Comments
class Solution:
def countSubarrays(self, arr, k):
def countAtMost(limit):
if limit < 0:

expression-contains-redundant-bracket-or-not.py /prakhardoneria/GFG/expression-contains-redundant-bracket-or-not.py
22 Views
0 Comments
class Solution():
def checkRedundancy(self, s):
st = []
for char in s:
if char == ')':

flattening-a-linked-list.py /prakhardoneria/GFG/flattening-a-linked-list.py
186 Views
0 Comments
class Solution:
def merge(self, a, b):
if not a: return b
if not b: return a

result = None

implement-undo-redo.py /prakhardoneria/GFG/implement-undo-redo.py
27 Views
0 Comments
class Solution:
def __init__(self):
self.history = []
self.future = []

def append(self, x):
sel
josephus-problem.py /prakhardoneria/GFG/josephus-problem.py
23 Views
0 Comments
class Solution:
def josephus(self, n, k):
if n == 1:
return 1
else:
return (self.jos
lemonade-change.py /prakhardoneria/GFG/lemonade-change.py
42 Views
0 Comments
class Solution:
def canServe(self, arr):
five = 0
ten = 0

for bill in arr:
if b
max-sum-subarray-of-size.py /prakhardoneria/GFG/max-sum-subarray-of-size.py
56 Views
0 Comments
class Solution:
def maxSubarraySum(self, arr, k):
n = len(arr)
if n < k:
return 0


max-xor-subarray-of-size-k.py /prakhardoneria/GFG/max-xor-subarray-of-size-k.py
43 Views
0 Comments
class Solution:
def maxSubarrayXOR(self, arr, k):
n = len(arr)
current_xor = 0

for i in ran
maximum-of-all-subarrays-of-size-k.py /prakhardoneria/GFG/maximum-of-all-subarrays-of-size-k.py
35 Views
0 Comments
from collections import deque

class Solution:
def maxOfSubarrays(self, arr, k):
n = len(arr)
dq = deque()

maximum-people-visible-in-a-line.py /prakhardoneria/GFG/maximum-people-visible-in-a-line.py
23 Views
0 Comments
class Solution:
def maxPeople(self, arr):
n = len(arr)
if n == 0:
return 0

visi
minimum-sprinklers.py /prakhardoneria/GFG/minimum-sprinklers.py
32 Views
0 Comments
class Solution:
def minMen(self, arr):
n = len(arr)
max_reach_at = [-1] * n

for i in range(
minimum-window-subsequence.py /prakhardoneria/GFG/minimum-window-subsequence.py
41 Views
0 Comments
class Solution:
def minWindow(self, s1, s2):
n1, n2 = len(s1), len(s2)
i, j = 0, 0
min_len = float('
next-element-with-greater-frequency.py /prakhardoneria/GFG/next-element-with-greater-frequency.py
29 Views
0 Comments
from collections import Counter

class Solution:
def nextFreqGreater(self, arr):
n = len(arr)
freq = Counter
police-and-thieves.py /prakhardoneria/GFG/police-and-thieves.py
37 Views
0 Comments
class Solution:
def catchThieves(self, arr, k):
n = len(arr)
p = 0
t = 0
res = 0


remove-k-digits.py /prakhardoneria/GFG/remove-k-digits.py
23 Views
0 Comments
class Solution:
def removeKdig(self, s, k):
if len(s) == k:
return "0"

stack = []

sort-an-array-of-0s-1s-and-2s4231.py /prakhardoneria/GFG/sort-an-array-of-0s-1s-and-2s4231.py
204 Views
0 Comments
class Solution:
def sort012(self, arr):
low = 0
mid = 0
high = len(arr) - 1

while m
stock-span-problem.py /prakhardoneria/GFG/stock-span-problem.py
31 Views
0 Comments
class Solution:
def calculateSpan(self, arr):
n = len(arr)
span = [0] * n
stack = []


subarrays-with-at-most-k-distinct-integers.py /prakhardoneria/GFG/subarrays-with-at-most-k-distinct-integers.py
42 Views
0 Comments
class Solution:
def countAtMostK(self, arr, k):
if k == 0:
return 0

n = len(arr)

sum-of-subarray-ranges.py /prakhardoneria/GFG/sum-of-subarray-ranges.py
27 Views
0 Comments
class Solution:
def subarrayRanges(self, arr):
n = len(arr)

def get_contribution(is_min):