CodeWithARB
CodeWithARB
  • 89
  • 17 323
Continuous Subarray Sum (LeetCode 523) (HashMap)
Watch at 1.25x or 1.5x
In this Video, I explained the solution for Continuous Subarray Sum problem. I have solved and explained using Hashmap.
Solution and Explaination of Leetcode POTD:
Question: leetcode.com/problems/continuous-subarray-sum/description/
Solution: leetcode.com/problems/continuous-subarray-sum/submissions/1281156337/
0:00 Understanding the Question
02:20 Building Intution
08:30 Approach
15:50 Implementation
20:11 Time and Space Complexity
#dsa #dsalgo #arrays #strings #hashmap #hashtable #leetcodemedium #leetcodeeasy #leetcode #array #strings #string #leetcodepotd #leetcode #leetcodetoday #potd #ContinuousSubarraySum #leetcodesolutions #LeetCode523 @CodeWithARB
Переглядів: 227

Відео

Replace Words (LeetCode 648) (HashMap)
Переглядів 4582 години тому
Watch at 1.25x or 1.5x In this Video, I explained the solution for Replace Words problem. I have solved and explained using Hashmap. we can also use hash table to reduce the time complexity more further with the slightest modification in Code. Solution and Explaination of Leetcode POTD: Question: leetcode.com/problems/replace-words/description/ Solution: leetcode.com/problems/replace-words/subm...
Hand of Straights (LeetCode 846) (HashMap)
Переглядів 3394 години тому
Watch at 1.25x or 1.5x In this Video, I explained the solution for Hand of Straights problem. I have solved and explained using Hashmap. we can also use hash table to reduce the time complexity more further with the slightest modification in Code. Solution and Explaination of Leetcode POTD: Question: leetcode.com/problems/hand-of-straights/description/ Solution: leetcode.com/problems/hand-of-st...
Find Common Characters (LeetCode 1002) (Arrays,Counting)
Переглядів 5477 годин тому
Watch at 1.25x or 1.5x In this Video, I explained the solution for Find Common Characters problem. Solution and Explaination of Leetcode POTD: Question: leetcode.com/problems/find-common-characters/description/ Solution: leetcode.com/problems/find-common-characters/submissions/1277988763/ 0:00 Understanding the Question 02:00 Building Intution 05:00 Correct Approach 10:05 Implementation #dsa #d...
Longest Palindrome (LeetCode 409) (Hashing, String)
Переглядів 2569 годин тому
Watch at 1.25x or 1.5x In this Video, I explained the solution for Longest Palindrome problem. Here, i explain the conditions of Palindrome and use hash table to solve this problem . Solution and Explaination of Leetcode POTD: Question: leetcode.com/problems/longest-palindrome/description/ Solution: leetcode.com/problems/longest-palindrome/submissions/1276951967/ 0:00 Understanding the Question...
Append Characters to String to Make Subsequence (LeetCode 2486) (Two Pointer Approach)
Переглядів 11812 годин тому
Watch at 1.25x or 1.5x In this Video, I explained the solution for Append Characters to String to Make Subsequence problem. Here, i explain how can i use two pointer approach to solve this problem . Solution and Explaination of Leetcode POTD: Question: leetcode.com/problems/append-characters-to-string-to-make-subsequence/description/ Solution: leetcode.com/problems/append-characters-to-string-t...
Lexicographically Minimum String After Removing Stars (LeetCode 3170) (Weekly Contest 400) (Heap)
Переглядів 45014 годин тому
Watch at 1.25x or 1.5x In this Video, i have explained the solution of Lexicographically Minimum String After Removing Stars problem. Here, i have explained the solution using Heap. You can learn how to implement and analyze the time and Space complexity For Custom Comparator - www.geeksforgeeks.org/custom-comparator-in-priority_queue-in-cpp-stl/ Solution and Explaination of Leetcode POTD: Ques...
Reverse String (LeetCode 344) (String)
Переглядів 11414 годин тому
Watch at 1.25x or 1.5x In this Video, I explained the solution for Reverse String problem. Here, i explain the solution using observation basics iteration in string. Solution and Explaination of Leetcode POTD: Question: leetcode.com/problems/reverse-string/description/ Solution: leetcode.com/problems/reverse-string/submissions/1274815250/ #dsa #strings #leetcodeeasy #leetcode #hashing #leetcode...
Score of a String (LeetCode 3110) (String, Maths)
Переглядів 16316 годин тому
Watch at 1.25x or 1.5x In this Video, I explained the solution forScore of a String problem. Here, i explain the solution using basics iteration in loop. Solution and Explaination of Leetcode POTD: Question: leetcode.com/problems/score-of-a-string/description/ Solution: leetcode.com/problems/score-of-a-string/submissions/1273803899/ #dsa #strings #leetcodeeasy #leetcode #hashing #leetcodepotd #...
Single Number III (LeetCode 260) (Hashmap, Bit Manipulation)
Переглядів 30519 годин тому
Watch at 1.25x or 1.5x In this Video, I explained the solution for Single Number III problem. Here, i explain the solution using hashmap and bit manipulation. I explained both the approaches point by point and also use some Xor properties. Solution and Explaination of Leetcode POTD: Question: leetcode.com/problems/single-number-iii/description/ Using Hashmap Solution1: leetcode.com/problems/sin...
Count Triplets That Can Form Two Arrays of Equal XOR (LeetCode 1442) (Bit Manipulation)
Переглядів 6821 годину тому
Watch at 1.25x or 1.5x In this Video, I explained the solution for Count Triplets That Can Form Two Arrays of Equal XOR problem. Here, i explain use Xor properties. Solution and Explaination of Leetcode POTD: Question: leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/description/ Brute Force Solution1: leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-eq...
Number of Steps to Reduce a Number in Binary Representation to One (LeetCode 1404) (Bits)
Переглядів 511День тому
Watch at 1.25x or 1.5x In this Video, I explained the solution for Number of Steps to Reduce a Number in Binary Representation to One problem. Here, i explain use bit properties and think in bits for any problem. Solution and Explaination of Leetcode POTD: Question: leetcode.com/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/description/ Solution: leetcode.com/probl...
Get Equal Substrings Within Budget (LeetCode 1208) (Sliding Window)
Переглядів 207День тому
Solution and Explaination of Leetcode POTD: See this video for better understanding: ua-cam.com/video/bdNXr-GoTCA/v-deo.html Question: leetcode.com/problems/get-equal-substrings-within-budget/description/ Solution: leetcode.com/problems/get-equal-substrings-within-budget/submissions/1269958833/ 0:00 Understanding the Questions 02:25 Building Intution 12:10 Approach 16:30 Implementation 19:32 Ti...
Special Array With X Elements Greater Than or Equal X (LeetCode 1608) (2 Approaches)
Переглядів 334День тому
Watch at 1.25x or 1.5x In this Video, i have explained the solution of Special Array With X Elements Greater Than or Equal X problem. Here, i have explained the solution using sorting and the optimize further using counting sort. You can learn how to implement and analyze the time and Space complexity. Solution and Explaination of Leetcode POTD: Question: leetcode.com/problems/special-array-wit...
Student Attendance Record II (LeetCode 552) (Hard) (DP)
Переглядів 304День тому
Student Attendance Record II (LeetCode 552) (Hard) (DP)
Word Break II (LeetCode 140) (Hard) (Recursion+ Backtracking)
Переглядів 17314 днів тому
Word Break II (LeetCode 140) (Hard) (Recursion Backtracking)
Maximum Score Words Formed by Letters (LeetCode 1255) (Hard (Recursion,Backtracking, Subsets)
Переглядів 29314 днів тому
Maximum Score Words Formed by Letters (LeetCode 1255) (Hard (Recursion,Backtracking, Subsets)
The Number of Beautiful Subsets (LeetCode 2597) (Recursion,Backtracking)
Переглядів 77114 днів тому
The Number of Beautiful Subsets (LeetCode 2597) (Recursion,Backtracking)
Palindrome Partitioning (LeetCode 131) (Recursion + Backtracking)
Переглядів 23514 днів тому
Palindrome Partitioning (LeetCode 131) (Recursion Backtracking)
Subsets (LeetCode 78) (Recursion + Backtracking, Bit Manipulation)
Переглядів 22614 днів тому
Subsets (LeetCode 78) (Recursion Backtracking, Bit Manipulation)
Sum of All Subset XOR Totals (LeetCode 1863) (Recursive,Bit Manipulation)
Переглядів 40714 днів тому
Sum of All Subset XOR Totals (LeetCode 1863) (Recursive,Bit Manipulation)
Find the Maximum Sum of Node Values (LeetCode 3068) (Hard) (Two Approached) (Tree, Sorting, Greedy)
Переглядів 25414 днів тому
Find the Maximum Sum of Node Values (LeetCode 3068) (Hard) (Two Approached) (Tree, Sorting, Greedy)
Distribute Coins in Binary Tree (LeetCode 979) (DFS, Preorder Traversal)
Переглядів 35921 день тому
Distribute Coins in Binary Tree (LeetCode 979) (DFS, Preorder Traversal)
Delete Leaves With a Given Value (LeetCode 1325) (Recursion, Postorder Traversal)
Переглядів 9521 день тому
Delete Leaves With a Given Value (LeetCode 1325) (Recursion, Postorder Traversal)
Evaluate Boolean Binary Tree (LeetCode 2331) (PreOrder Traversal)
Переглядів 15121 день тому
Evaluate Boolean Binary Tree (LeetCode 2331) (PreOrder Traversal)
Find the Safest Path in a Grid (LeetCode 2812) (MultiSource BFS, Heap)
Переглядів 58221 день тому
Find the Safest Path in a Grid (LeetCode 2812) (MultiSource BFS, Heap)
Path with Maximum Gold (LeetCode 1219) (Recursion, Backtracking)
Переглядів 26921 день тому
Path with Maximum Gold (LeetCode 1219) (Recursion, Backtracking)
Score After Flipping Matrix (LeetCode 861) (Bit Manipulation)
Переглядів 48321 день тому
Score After Flipping Matrix (LeetCode 861) (Bit Manipulation)
Largest Local Values in a Matrix (LeetCode 2373)
Переглядів 38921 день тому
Largest Local Values in a Matrix (LeetCode 2373)
K-th Smallest Prime Fraction (LeetCode 786) (Sorting, Heap)
Переглядів 67828 днів тому
K-th Smallest Prime Fraction (LeetCode 786) (Sorting, Heap)

КОМЕНТАРІ

  • @suman-majhi
    @suman-majhi 6 годин тому

    You should have mention my name, as its originally from my solution

    • @CodeWithARB
      @CodeWithARB 3 години тому

      LOL, I don't need to see any solution for these kind of questions. 😂

  • @KishanKumar-cl2zq
    @KishanKumar-cl2zq 9 годин тому

    Nice Explanation

    • @CodeWithARB
      @CodeWithARB 9 годин тому

      Thank you. Please share the Channel.

  • @CodeWithARB
    @CodeWithARB 11 годин тому

    Correction: Space Complexity-> O(K), Because we are performing the modulus operation on the sum before inserting it into the Map. Thank you

  • @jmmusicyt
    @jmmusicyt День тому

    failing for test case 126 with time limit exceeds

    • @CodeWithARB
      @CodeWithARB 13 годин тому

      Not possible bro. I have submitted the solution in Video. Also, you can check the solution link in the description

  • @jmmusicyt
    @jmmusicyt День тому

    failing for test 126

  • @vedanta-xw3se
    @vedanta-xw3se День тому

    Nice Explaination

    • @CodeWithARB
      @CodeWithARB День тому

      Thank you.Please share the channel

  • @vigneshs1852
    @vigneshs1852 День тому

    i think using trie will be optimal, i used the same logic to solve and result in suboptimal results..Typical brute force. I dont know about trie till now, i need to revisit this..

    • @CodeWithARB
      @CodeWithARB День тому

      Yes,Trie is an optimal solution. I will upload the Trie solution very soon. I have not included the Trie solution in this video due to busy schedule. Hope you Understand. Thank you

  • @chayangupta6881
    @chayangupta6881 2 дні тому

    nice explanation bro ..Thank you..

    • @CodeWithARB
      @CodeWithARB День тому

      Thanks for the Feedback. Please share the Channel 🙂

  • @CodeWithARB
    @CodeWithARB 3 дні тому

    I forgot to mention the time and space complexity in the video. Time Complexity: O(N * M* 26), where N is the length of the words array and M is the average length of word. Space Complexity: O(26 * 2) -> O(1) Thank you

    • @venkadeshb7973
      @venkadeshb7973 3 дні тому

      isn't the time complexity O(N * maxLengthofWord * 26) ?

    • @CodeWithARB
      @CodeWithARB 3 дні тому

      Right, Thanks for pointing out. You can take maxLengthofWord or precisely it is AverageLengthOfWord

  • @akshayrajput6027
    @akshayrajput6027 6 днів тому

    Bro, This channel deserves more reach. Thanks for explaination

    • @CodeWithARB
      @CodeWithARB 6 днів тому

      Thank you so much. Please share the channel among your friends

  • @ravitejaw4604
    @ravitejaw4604 6 днів тому

    The leetcode question description was terrible, thanks for the explanation. I was trying to solve using a Stack, but got stuck.

    • @CodeWithARB
      @CodeWithARB 6 днів тому

      No worries bro. It happens. Hope you liked it. Thank you

  • @tarunkumarreddy5020
    @tarunkumarreddy5020 6 днів тому

    nice explanation broo

    • @CodeWithARB
      @CodeWithARB 6 днів тому

      Thank you so much. Please share the channel among your friends.

  • @Shiva-ne3et
    @Shiva-ne3et 6 днів тому

    good explanation

    • @CodeWithARB
      @CodeWithARB 6 днів тому

      Thank you. Please Share the channel among your Friends

  • @abhishekborkar6405
    @abhishekborkar6405 8 днів тому

    kya samjaya bhai aapne 🫡 thanks, sb clear ho gya'

    • @CodeWithARB
      @CodeWithARB 8 днів тому

      Thanks bhai . Please share the channel among your friends

  • @ashutoshtiwari5325
    @ashutoshtiwari5325 10 днів тому

    Liked the way you explained.

  • @arnavbahuguna390
    @arnavbahuguna390 10 днів тому

    the part where you explained ans+carry is unclear; why cant the msb(leftmost) bit require 2 operations?

    • @CodeWithARB
      @CodeWithARB 10 днів тому

      Sorry for that. Let me explain. We need to convert the string to 1. Binary representation of 1 is 001,right ? We need to worry about the bits till msb only. So, msb is already a setbit (i.e 1) After doing all possible operations just before msb(from right to left) there can be two possible cases:- 1) Either the carry is 1 -> it means that when this 1 will get add to msb, it will generate an 1 in left and an extra 0 to it right and which we need to remove, so for remove that 0 leads to 1 operation Ex-> 0010 -> suppose carry is 1 on the msb part ,so after addition it will becomes to 0100 -> so, we get an extra 0 which we need to remove by dividing by 2,so thats leads to an extra operation 2) Or the carry is 0 -> It means that if we add 1 with 0 ,it will lead to 1,so ultimately we need only 1 ,so we don't need to any operation so, for implementation i have just added carry to the final ans because finally it depends on the carry value that we will need an extra operation or not. Hope you understand it. Thank you

  • @armaanshoaib
    @armaanshoaib 13 днів тому

    very hard indeed😅, if they ask this question in interview, that means they don't want to hire you😂😂

    • @CodeWithARB
      @CodeWithARB 12 днів тому

      Some top companies might ask you these types of questions in Interview.

  • @CodeWithARB
    @CodeWithARB 13 днів тому

    1) Correction- 6:30 If the student is present/absent at any day then student is not consecutive late now, so late must be 0 2) We can also do it Iteratively . After this you must try to do it by your own. Thank you

  • @saitejareddy3404
    @saitejareddy3404 15 днів тому

    Hii atul can u pls do contest problems also your explanation is perfect, for weekly contest problems from Leetcode also..

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

    I like the way that you use text for your diagrams and that you code your solutions live.

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

    Good one

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

    Nice explanation

  • @none9304
    @none9304 18 днів тому

    11:15 bro i think some godzilla is there

    • @CodeWithARB
      @CodeWithARB 17 днів тому

      Sorry about that 😂. My roommate was doing it.

  • @CodeWithARB
    @CodeWithARB 22 дні тому

    Note->. This question is about PostOrder (left, right, root) Traversal. I mentioned PreOrder Traversal by mistake. Thank you.

  • @anushdubey01
    @anushdubey01 24 дні тому

    This is really helpful and easy to understand! Thank You.

  • @CodeWithARB
    @CodeWithARB 25 днів тому

    Note-> After coming to any cell from its parent ,it will can only move in 3 directions. So, precisely you can also say that the time complexity will be O(3^N). Thank you

  • @DineshDinesh-vw3uj
    @DineshDinesh-vw3uj 26 днів тому

    Very Good explanation, keep your streak daily buy posting these explanation videos

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

    We can place a 1 in the first row by first flipping 0th column and then flipping the rows that contain 0 in the first position. So, why we have not chosen this path? Is there any proof?

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

      I think you have not watched the full video. I suggest you to watch again. Don't go directly to the implementation part. Thank you

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

      @@CodeWithARB No, this is not true, you have not explained the proof of your implementation, there are two ways to reach the target, and both yield the same result. However, in interviews, it's important to consider both approaches and provide proof for our chosen method.

    • @nachiketsahasrabudhe6882
      @nachiketsahasrabudhe6882 24 дні тому

      Here is a proposed proof, though I think its fairly clear from the explanation that the solution is optimal. Its a proof by induction, with induction on columns. The base case of 1st column is not discussed here, its optimality is discussed in the video. Let r_{i,j} denote the score by considering i^th row and only considering its first 'j' columns. Let mat[i][j] denote the value in binary matrix at location (i, j). If score obtained till 'k'^th column is optimal, then for the (k+1)st column we have score of a row as: r_{i,k} * 2 + mat[i][k+1]. And total score as: r_{0,k} * 2 + mat[0][k+1] + r_{1,k} *2 + mat[1][k+1] + ...+ r_{m -1, k} * 2 + mat[m-1][k+1] = 2 * ( r_{0, k} + r_{1, k} + ... + r_{m-1,k} ) + ( mat[0][k+1] + mat[1][k+1] + ..+ mat[m-1][k+1] ) The sum in the first bracket is optimal by induction. The sum from the second bracket would be optimal if number of '1''s in (k +1)st columns is maximized. Since the algorithm precisely does it the score obtained by considering only first k + 1 columns using this algorithm is optimal. Hence the score by considering all n+1 columns using this algorithm is optimal.

  • @CodeWithARB
    @CodeWithARB 29 днів тому

    Note-> Just use pen and paper to understand this by taking an example and dry run by yourself. Thank you

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

    its O(N) problem

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

      Are you referring to Time or Space Complexity ?

    • @mendor0
      @mendor0 29 днів тому

      @@CodeWithARB time

    • @CodeWithARB
      @CodeWithARB 29 днів тому

      @@mendor0 And how will you do that ? Are you referring to the Radix sort approach ?

    • @mendor0
      @mendor0 29 днів тому

      @@CodeWithARB start with nth_element to find top k, then counting sort for remaining elements valued less then k (elements over k should be executed in _ANY_ order first)

  • @Ari-pq4db
    @Ari-pq4db Місяць тому

    Nice , thanks 👍

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

    Note-> For checking the number exist in unordered_map or unordered_set, average time is O(1) and O(N) at worst. In this, constraints are low, so time will be O(1). Thank you

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

    this mentioned in the editorial can you prove it: The XOR function is equivalent to subtraction under modulo 2. All bits are independently calculated in the XOR function, where for each bit, the output is true when there is an odd number of true inputs.

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

      Yeah right. So, Xor function is equivalent to addition/subtraction under modulo 2. For subtraction, if you try to subtract any two number and see its binary representation that will be equals to Xor operation between them Suppose we subtract 4 from 6. 6+(-4) = 10 6 -> 110 4 -> 100 6^4 = 010 = 2 here modulo 2 is to show that when there are even number of occurences then the result will be always 0 (false) and for odd, it will be 1(true) which is the equivalent to XOR properties.

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

    explanation is bad try better

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

      Sorry for that. The problem was that the original video which i made was not working properly due to some reasons so i made a just go through explaination.

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

    -> Use Pen and Paper and take examples and try to understand yourself. You will get more clarity. Thank you

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

    27:38 -> Time complexity will be 10^n instead of 9^n because number can be possible from O to 9. So ,total numbers are 10. Same from Space complexity . Thank you

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

    Very Nicely Explained

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

      Thank you. Please like and Subscribe 😃

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

    Correction : 16:41 -> Time complexity - O(NlogN) instead of O(N) because i am also reversing the string whose length will be the height of tree and the height of tree is log2(N).

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

    If you want to provide any feedback, please comment. It will help me to improve. Thank you.

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

    If you want to provide any feedback, please comment. It will help me to improve. Thank you.

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

    If you want to provide any feedback, please comment. It will help me to improve. Thank you.

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

    If you want to provide any feedback, please comment. It will help me to improve. Thank you.

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

    If you want to provide any feedback, please comment. It will help me to improve. Thank you.

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

    If you want to provide any feedback, please comment. It will help me to improve. Thank you.

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

    If you want to provide any feedback, please comment. It will help me to improve. Thank you.

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

    If you want to provide any feedback, please comment. It will help me to improve. Thank you.

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

    If you want to provide any feedback, please comment. It will help me to improve. Thank you.

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

    If you want to provide any feedback, please comment. It will help me to improve. Thank you.

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

    If you want to provide any feedback, please comment. It will help me to improve. Thank you.