Orkhan Gasanov
Orkhan Gasanov
  • 166
  • 18 915
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
Переглядів: 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
Database - CAP Theorem
Переглядів 834 місяці тому
Database - CAP Theorem
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

КОМЕНТАРІ

  • @gowtham7888
    @gowtham7888 9 днів тому

    Nice Explanation Expecting more like this Content

  • @azharahmad3595
    @azharahmad3595 16 днів тому

    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

    • @orkhan-1
      @orkhan-1 16 днів тому

      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

  • @sabarishkrishnamoorthi7985
    @sabarishkrishnamoorthi7985 19 днів тому

    I am your 400th subscriber, keep growing, we will support you, thank for the video, keep it up

  • @crekso398
    @crekso398 19 днів тому

    thanks a lot it was a clear explanation

  • @md_pedia1
    @md_pedia1 19 днів тому

    that was really helpful

  • @NibinBinoy3248
    @NibinBinoy3248 26 днів тому

    Great explanation ❤

  • @bairunagarajuindian8509
    @bairunagarajuindian8509 Місяць тому

    Thank you❤

  • @johnlocke4695
    @johnlocke4695 Місяць тому

    Excellent explanation. Keep it going

  • @user-oc7dv7xn9l
    @user-oc7dv7xn9l 2 місяці тому

    amazing explanation!

  • @FrezoreR
    @FrezoreR 2 місяці тому

    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.

    • @orkhan-1
      @orkhan-1 2 місяці тому

      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

    • @FrezoreR
      @FrezoreR 2 місяці тому

      @@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 :)

    • @orkhan-1
      @orkhan-1 2 місяці тому

      By requirement array only contains positive integers; thus, the random pick must be between 1 and totalSum

    • @FrezoreR
      @FrezoreR 2 місяці тому

      @@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 :)

    • @orkhan-1
      @orkhan-1 2 місяці тому

      You're absolutely right! range [0, w.length - 1] refers to index whereas we need number between 1 and totalSum

  • @ElFox
    @ElFox 2 місяці тому

    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)

  • @ElFox
    @ElFox 2 місяці тому

    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

  • @ElFox
    @ElFox 2 місяці тому

    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)

  • @ElFox
    @ElFox 2 місяці тому

    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

  • @ElFox
    @ElFox 3 місяці тому

    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)

  • @throwawayaccount1389
    @throwawayaccount1389 5 місяців тому

    after hours of searching found the perfect video

  • @varunpunia11
    @varunpunia11 5 місяців тому

    It's because of you that i finally understand this question...Love from india!

  • @Nerddog12344
    @Nerddog12344 6 місяців тому

    You really deserve more view ❤

  • @Nerddog12344
    @Nerddog12344 6 місяців тому

    Nice explanation

  • @amitjosh79
    @amitjosh79 6 місяців тому

    Python doesn’t have red black tree api to get floor & ceil keys ?

    • @orkhan-1
      @orkhan-1 6 місяців тому

      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

  • @karibui494
    @karibui494 6 місяців тому

    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))

  • @edwinndiritu9802
    @edwinndiritu9802 6 місяців тому

    A code example would be nice

    • @orkhan-1
      @orkhan-1 6 місяців тому

      Added in description

    • @MRT122YT
      @MRT122YT 6 місяців тому

      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)

  • @wobby_1974
    @wobby_1974 6 місяців тому

    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.

    • @orkhan-1
      @orkhan-1 6 місяців тому

      Thank you for your comment! k as input size of the array may vary; the worst-case performance time complexity is O (N^2)

    • @warvinn
      @warvinn 6 місяців тому

      @@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)

    • @dewpta4717
      @dewpta4717 6 місяців тому

      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) ).

  • @luiscanterohernandez6668
    @luiscanterohernandez6668 6 місяців тому

    Good video

    • @orkhan-1
      @orkhan-1 6 місяців тому

      Thank you!

  • @puppergump4117
    @puppergump4117 7 місяців тому

    Is this any different from just indexing the strings to compare them?

    • @orkhan-1
      @orkhan-1 7 місяців тому

      No. Indexing String is basically Two Pointers approach.

    • @puppergump4117
      @puppergump4117 7 місяців тому

      @@orkhan-1 Ok, I know some people directly increment/dereference pointers. They're old people though lol.

  • @SelfMadeSystem
    @SelfMadeSystem 7 місяців тому

    I liek 👍

  • @shubhamsakhare3069
    @shubhamsakhare3069 9 місяців тому

    Brilliant explanation

    • @orkhan-1
      @orkhan-1 9 місяців тому

      Thank you!

  • @user-mc1gl5ex4f
    @user-mc1gl5ex4f 10 місяців тому

    Great Job sir

    • @orkhan-1
      @orkhan-1 10 місяців тому

      Thank you!