Skip to content

Instantly share code, notes, and snippets.

View Zarifboyev's full-sized avatar
🎯
Focusing

Javohir Zarifboyev Zarifboyev

🎯
Focusing
View GitHub Profile
@Zarifboyev
Zarifboyev / sol.py
Created October 4, 2025 14:29
Merge sort algoritmi by Javohir Zarifboyev 942-23
def merge_sort(massiv1, massiv2):
i = 0
j = 0
merged_list = []
while i < len(massiv1) and j < len(massiv2):
if massiv1[i] <= massiv2[j]:
merged_list.append(massiv1[i])
i += 1
else:
merged_list.append(massiv2[j])
@Zarifboyev
Zarifboyev / solution.py
Created October 4, 2025 13:23
2-amaliyot topshirig'i 2-masalamning yechimi. Zarifboyev J. 942-23
def computeLPSArray(pattern):
"""
Computes the LPS (Longest Proper Prefix which is also a Suffix) array
for the given pattern.
Time Complexity: O(M), where M is the length of the pattern.
"""
M = len(pattern)
lps = [0] * M
# Length of the previous longest prefix suffix
@Zarifboyev
Zarifboyev / solution.py
Created October 31, 2024 12:02
Juft raqamli natural son
def count_even(digit, num_zeroes):
# The arguments encode a number that only has one non-zero digit, the first:
# - digit: the most significant digit (1..9)
# - num_zeroes: the count of trailing zeroes
# Returns the count of numbers less than this encoded number that have at
# least one even digit
return (10**num_zeroes * digit # count all numbers
# exclude numbers with fewer digits and only odd digits:
- ((5**(num_zeroes+1)-1)//4-1)
# exclude numbers with same digit count and only odd digits,
@Zarifboyev
Zarifboyev / MainActivity.java
Created September 15, 2020 16:49
Calculator ilovasining natijani hisoblash metodi
buttonEqual.setOnClickListener(v -> {
process = textViewInput.getText().toString();
process = process.replaceAll("×", "*");
process = process.replaceAll("%", "/100");
process = process.replaceAll("÷", "/");
Context rhino = Context.enter();
rhino.setOptimizationLevel(-1);