![Orkhan Gasanov](/img/default-banner.jpg)
- 166
- 18 915
Orkhan Gasanov
United States
Приєднався 17 лип 2017
Hi Everyone, it's Orkhan! 👋
I'm a Lead Software Engineer with a passion for tech, and I love sharing my knowledge and experience. On this channel, you'll find a variety of videos covering a wide range of topics, from problem-solving to software development best practices and beyond.
I'm a Lead Software Engineer with a passion for tech, and I love sharing my knowledge and experience. On this channel, you'll find a variety of videos covering a wide range of topics, from problem-solving to software development best practices and beyond.
LeetCode - 234. Palindrome Linked List | Python | Java
00:00 - Step-by-Step Explanation
04:10 - Python Code
6:40 - Java Code
Python Code - github.com/Orkhan-1/LeetCode/blob/main/python/00234_palindrome_linked_list.py
Java Code - github.com/Orkhan-1/LeetCode/blob/main/java/00234_palindrome_linked_list.java
leetcode 234
#leetcode #softwareengineering #applicationengineering #coding #programming #linkedlist
04:10 - Python Code
6:40 - Java Code
Python Code - github.com/Orkhan-1/LeetCode/blob/main/python/00234_palindrome_linked_list.py
Java Code - github.com/Orkhan-1/LeetCode/blob/main/java/00234_palindrome_linked_list.java
leetcode 234
#leetcode #softwareengineering #applicationengineering #coding #programming #linkedlist
Переглядів: 102
Відео
LeetCode - 516. Longest Palindromic Subsequence | Dynamic Programming Bottom Up | Python | Java
Переглядів 258Місяць тому
00:00 - Step-by-Step Explanation 07:39 - Python Code 10:14 - Java Code Python Code - github.com/Orkhan-1/LeetCode/blob/main/python/00516_longest_palindromic_subsequence.py Java Code - github.com/Orkhan-1/LeetCode/blob/main/java/00516_longest_palindromic_subsequence.java leetcode 516 #leetcode #softwareengineering #applicationengineering #coding #programming
Sorting Algorithms - Bubble Sort | Python | Java
Переглядів 4232 місяці тому
00:00 - Step-by-Step Explanation 03:38 - Python Code 5:15 - Java Code Python Code - github.com/Orkhan-1/Data-Structures-And-Algorithms/blob/main/Algorithms/Sorting Algorithms/Bubble Sort/bubble_sort.py Java Code - github.com/Orkhan-1/Data-Structures-And-Algorithms/blob/main/Algorithms/Sorting Algorithms/Bubble Sort/bubble_sort.java #leetcode #softwareengineering #applicationengineering #coding ...
LeetCode - 443. String Compression | Two Pointers Technique | Python | Java
Переглядів 1912 місяці тому
00:00 - Step-by-Step Explanation 04:11 - Python Code 6:28 - Java Code Python Code - github.com/Orkhan-1/LeetCode/blob/main/python/00443_string_compression.py Java Code - github.com/Orkhan-1/LeetCode/blob/main/java/00443_string_compression.java leetcode 443 #leetcode #softwareengineering #applicationengineering #coding #programming
LeetCode - 54. Spiral Matrix | Array | Python | Java
Переглядів 602 місяці тому
00:00 - Step-by-Step Explanation 04:18 - Python Code 06:48 - Java Code Python Code - github.com/Orkhan-1/LeetCode/blob/main/python/00054_spiral_matrix.py Java Code - github.com/Orkhan-1/LeetCode/blob/main/java/00054_spiral_matrix.java leetcode 54 #leetcode #softwareengineering #applicationengineering #coding #programming #algorithm
LeetCode - 542. 01 Matrix | BFS | Python | Java
Переглядів 602 місяці тому
00:00 - Description 07:55 - Python Code 11:24 - Java Code Python Code - github.com/Orkhan-1/LeetCode/blob/main/python/00542_zero_one_matrix.py Java Code - github.com/Orkhan-1/LeetCode/blob/main/java/00542_zero_one_matrix.java leetcode 542 #leetcode #softwareengineering #applicationengineering #coding #programming #algorithm #bfs
LeetCode - 2443. Sum of Number and Its Reverse | Math | Python | Java
Переглядів 582 місяці тому
00:00 - Step-by-Step Explanation 04:24 - Python Code 06:08 - Java Code Python Code - github.com/Orkhan-1/LeetCode/blob/main/python/02443_sum_of_number_and_its_reverse.py Java Code - github.com/Orkhan-1/LeetCode/blob/main/java/02443_sum_of_number_and_its_reverse.java JS Code - github.com/Orkhan-1/LeetCode/blob/main/js/02443_sum_of_number_and_its_reverse.js Go Code - github.com/Orkhan-1/LeetCode/...
LeetCode - 118. Pascal's Triangle Elements | Array | Python | Java
Переглядів 332 місяці тому
00:00 - Step-by-Step Explanation 03:29 - Python Code 05:21 - Java Code Python Code - github.com/Orkhan-1/LeetCode/blob/main/python/00118_pascals_triangle.py Java Code - github.com/Orkhan-1/LeetCode/blob/main/java/00118_pascals_triangle.java leetcode 118 #leetcode #softwareengineering #applicationengineering #coding #programming #algorithm
LeetCode - 13. Roman to Integer | Math | Python | Java
Переглядів 242 місяці тому
00:00 - Step-by-Step Explanation 03:46 - Python Code 05:05 - Java Code Python Code - github.com/Orkhan-1/LeetCode/blob/main/python/00013_roman_to_integer.py Java Code - github.com/Orkhan-1/LeetCode/blob/main/java/00013_roman_to_integer.java leetcode 13 #leetcode #softwareengineering #applicationengineering #coding #programming #algorithm #math
LeetCode - 704. Binary Search | Python | Java
Переглядів 352 місяці тому
00:00 - Step-by-Step Explanation 02:20 - Python Code 04:03 - Java Code Python Code - github.com/Orkhan-1/LeetCode/blob/main/python/00704_binary_search.py Java Code - github.com/Orkhan-1/LeetCode/blob/main/java/00704_binary_search.java leetcode 704 #leetcode #softwareengineering #applicationengineering #coding #programming #algorithm #binarysearch
LeetCode - 226. Invert Binary Tree | Recursion | Binary Tree | Python | Java
Переглядів 342 місяці тому
00:00 - Step-by-Step Explanation 01:15 - Python Code 02:31 - Java Code Python Code - github.com/Orkhan-1/LeetCode/blob/main/python/00226_invert_binary_tree.py Java Code - github.com/Orkhan-1/LeetCode/blob/main/java/00226_invert_binary_tree.java leetcode 226 #leetcode #softwareengineering #applicationengineering #coding #programming #algorithm #binarytree #recursion
LeetCode - 921. Minimum Add to Make Parentheses Valid | Python | Java
Переглядів 182 місяці тому
00:00 - Step-by-Step Explanation 04:20 - Python Coding 05:14 - Java Coding Python Code - github.com/Orkhan-1/LeetCode/blob/main/python/00921_minimum_add_to_make_parentheses_valid.py Java Code - github.com/Orkhan-1/LeetCode/blob/main/java/00921_minimum_add_to_make_parentheses_valid.java JS Code - github.com/Orkhan-1/LeetCode/blob/main/js/00921_minimum_add_to_make_parentheses_valid.js Go Code - g...
LeetCode - 2148. Count Elements With Strictly Smaller and Greater Elements | Array | Python | Java
Переглядів 323 місяці тому
00:00 - Step-by-Step Explanation 02:16 - Python Code 03:51 - Java Code Python Code - github.com/Orkhan-1/LeetCode/blob/main/python/02148_count _elements_with_strictly_smaller_and_greater_elements.py Java Code - github.com/Orkhan-1/LeetCode/blob/main/java/02148_count_elements_with_strictly_smaller_and_greater_elements.java leetcode 2148 #leetcode #softwareengineering #applicationengineering #cod...
LeetCode - 1010. Pairs of Songs With Total Durations Divisible by 60 | Hash Table | Python | Java
Переглядів 783 місяці тому
00:00 - Step-by-Step Explanation 06:10 - Python Code 08:04 - Java Code Python Code - github.com/Orkhan-1/LeetCode/blob/main/python/01010_pairs_of_songs_with_total_durations_divisible_by_60.py Java Code - github.com/Orkhan-1/LeetCode/blob/main/java/01010_pairs_of_songs_with_total_durations_divisible_by_60.java leetcode 1010 #leetcode #softwareengineering #applicationengineering #coding #programm...
LeetCode - 380. Insert Delete GetRandom O(1) | Design | Java
Переглядів 533 місяці тому
00:00 - Step-by-Step Explanation 07:13 - Coding Code on GitHub - github.com/Orkhan-1/LeetCode/blob/main/java/00380_insert_delete_get_random.java leetcode 380 #leetcode #softwareengineering #applicationengineering #coding #programming
LeetCode - 731. My Calendar II | Java
Переглядів 303 місяці тому
LeetCode - 731. My Calendar II | Java
LeetCode - 71. Simplify Path | Stack | Java
Переглядів 713 місяці тому
LeetCode - 71. Simplify Path | Stack | Java
LeetCode - 347. Top K Frequent Elements | Heap | Priority Queue | Java
Переглядів 574 місяці тому
LeetCode - 347. Top K Frequent Elements | Heap | Priority Queue | Java
LeetCode - 8. String to Integer (atoi) | String | Java
Переглядів 554 місяці тому
LeetCode - 8. String to Integer (atoi) | String | Java
LeetCode - 802. Find Eventual Safe States | DFS | Java
Переглядів 454 місяці тому
LeetCode - 802. Find Eventual Safe States | DFS | Java
LeetCode - 1043. Partition Array for Maximum Sum | Dynamic Programming | Java
Переглядів 624 місяці тому
LeetCode - 1043. Partition Array for Maximum Sum | Dynamic Programming | Java
LeetCode - 435. Non-overlapping Intervals | Java
Переглядів 1054 місяці тому
LeetCode - 435. Non-overlapping Intervals | Java
LeetCode - 686. Repeated String Match | String | Java
Переглядів 1564 місяці тому
LeetCode - 686. Repeated String Match | String | Java
LeetCode - 303. Range Sum Query - Immutable | Segment Tree | Java
Переглядів 644 місяці тому
LeetCode - 303. Range Sum Query - Immutable | Segment Tree | Java
LeetCode - 307. Range Sum Query - Mutable | Binary Indexed Tree | Java
Переглядів 855 місяців тому
LeetCode - 307. Range Sum Query - Mutable | Binary Indexed Tree | Java
LeetCode - 684. Redundant Connection | Union-Find | Java
Переглядів 755 місяців тому
LeetCode - 684. Redundant Connection | Union-Find | Java
LeetCode - 1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance | Java
Переглядів 3175 місяців тому
LeetCode - 1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance | Java
LeetCode - 451. Sort Characters By Frequency | Max Heap | Java
Переглядів 1135 місяців тому
LeetCode - 451. Sort Characters By Frequency | Max Heap | Java
LeetCode - 1615. Maximal Network Rank | Hash Table | Java
Переглядів 1075 місяців тому
LeetCode - 1615. Maximal Network Rank | Hash Table | Java
Nice Explanation Expecting more like this Content
Thank you!
you didn't take into count, even and odd number of elements. There will be a case where fast.next.next will give NullPointer, we need to have that check
Thank you for your comment! Before calling fast.next.next we make sure that fast.next is not null. It helps us to avoid NPE
I am your 400th subscriber, keep growing, we will support you, thank for the video, keep it up
Thank you!
thanks a lot it was a clear explanation
that was really helpful
Thanks!
Great explanation ❤
Thanks!
Thank you❤
Excellent explanation. Keep it going
Thanks!
amazing explanation!
Thanks!
Generally a great video. I think it would help the viewers if you explain in the code section why you have +1 for the target.
Thank you for your comment! Since the nextInt method generates a number in the range 0 to totalSum-1, we add +1 to ensure that our target is in the range 1 to totalSum
@@orkhan-1 Thanks for the answer. Why not generate directly to totalSum? I.e. why do we want the min value to be 1? It might be an obvious question, but I just want to make sure I fully understand the solution :)
By requirement array only contains positive integers; thus, the random pick must be between 1 and totalSum
@@orkhan-1 Ah yes. I was thinking of the requirement that said: randomly picks an index in the range [0, w.length - 1] But that translates to 1 - maxSum in our prefixSum, since the smallest sum will be 1, if all weights are 1 or larger. Let me know if I got that wrong somewhere. It helps to paraphrase it :)
You're absolutely right! range [0, w.length - 1] refers to index whereas we need number between 1 and totalSum
One more short solution: class Solution(object): def countElements(self, nums): min_el = min(nums) max_el = max(nums) return sum(1 for num in nums if min_el < num < max_el)
Thanks!
Here is one more ineresting solution: class Solution: # Time Complexity: O(n) # Space Complexity: O(1) def numPairsDivisibleBy60(self, time: List[int]) -> int: remainder_counts = [0] * 60 count = 0 for t in time: remainder = t % 60 if remainder == 0: count += remainder_counts[0] else: count += remainder_counts[60 - remainder] remainder_counts[remainder] += 1 return count
Example on Python (using sorting): from collections import Counter class Solution: def frequencySort(self, s: str) -> str: # Count character frequencies using Counter char_counts = Counter(s) # Sort characters by frequency (descending) and then by character sorted_chars = sorted(char_counts.items(), key=lambda item: (-item[1], item[0])) # Build the result string character by character result = [] for char, count in sorted_chars: result.append(char * count) return ''.join(result)
Thanks!
Example on Python (using priority queue): from collections import Counter class Solution: def frequencySort(self, s: str) -> str: # Count character frequencies using Counter char_counts = Counter(s) # Create a min-heap to store (frequency, character) tuples min_heap = [(-count, char) for char, count in char_counts.items()] heapq.heapify(min_heap) # Build the min-heap # Build the result string character by character result = [] while min_heap: count, char = heapq.heappop(min_heap) result.append(char * -count) # Append character repeated by its count return ''.join(result) # Join the characters from the result list
Thanks!
Solution in Python: from collections import Counter class Solution: def topKFrequent(self, nums: List[int], k: int) -> List[int]: # Creating the counter: O(n), where n is the length of the nums list. # Building the heap and extracting elements: O(k log n) using heapq.nlargest. # Overall: O(n + k log n) which is approximately O(n log n) in most cases since k # is typically much smaller than n. counter = Counter(nums) # The counter dictionary: O(n) in the worst case (all elements are unique). # The heap created by nlargest: O(k). # Overall: O(n + k), which is also approximately O(n) in most cases due to the smaller value of k. return heapq.nlargest(k, counter.keys(), counter.get)
Thanks!
after hours of searching found the perfect video
Thanks!
explain the tc and sc also in ur videos @@orkhan-1
It's because of you that i finally understand this question...Love from india!
Thanks!
You really deserve more view ❤
Thanks!
Nice explanation
Thanks!
Python doesn’t have red black tree api to get floor & ceil keys ?
Python doesn’t have a built-in red-black tree data structure in the standard library. However, sortedcontainers library provides a SortedDict class, which is implemented using a red-black tree
It must be noted that you can only remove the second loop is k is fixed, if k can change you will have the same time complexity of O(k(n-k))
A code example would be nice
Added in description
arr = [2,1,4,6,5,1,3,5,2,3,4] k = 3 start = 0 summ = 0 max_summ = 0 for end in range(len(arr)): summ += arr[end] if end - start + 1 == k: max_summ = max(max_summ,summ) summ -= arr[start] start += 1 print(max_summ)
I think its a bit misleading to say that the naive algorithm has a Time Complexity of O(n²), as the runtime depends on the array size n and the number of consecutive elements k. So as the array size would increase and k stays constant the algorithm would actually have a linear runtime, but if both increase the total time Complexity would increase quadratically. Which of course the second algorithm solves.
Thank you for your comment! k as input size of the array may vary; the worst-case performance time complexity is O (N^2)
@@orkhan-1 The worst-case performance is only O(n^2) when k grows with input size, which would be unusual but not impossible. Generally speaking it is preferred to call this time complexity O(k⋅n)
I think O(n^2) is an okay bound, but its not tight. Additionally, k = n would not be the worst case because then there is just one window and we can just sum up the array to get the solution. Alternative analysis: For an array of size n there are n - k + 1 subarrays (windows) of size k > 0. For each of these windows we need to sum up k items so, total number of operations are: (n - k + 1) * k => O( k(n - k) ).
Good video
Thank you!
Is this any different from just indexing the strings to compare them?
No. Indexing String is basically Two Pointers approach.
@@orkhan-1 Ok, I know some people directly increment/dereference pointers. They're old people though lol.
I liek 👍
Thanks!
Brilliant explanation
Thank you!
Great Job sir
Thank you!