Techdose

Techdose

This channel features Programming, MATHS ,Data Structures & Algorithms,Technology,Tutorials etc. Browse our channel to know more. SUBSCRIBE to never miss our videos :) SUGGEST your likes and dislikes in our videos so that we can improve on our flaws and give you a seamless experience.

Factors of a number

Factors of a number

Bitset

Bitset

Count number of digits

Count number of digits

Median of 2 sorted arrays

Median of 2 sorted arrays

Пікірлер

  • @nandanimadhukar
    @nandanimadhukar7 сағат бұрын

    very good explanation and technique

  • @techdose4u
    @techdose4u4 сағат бұрын

    Thanks

  • @HeloHi-dp6up
    @HeloHi-dp6up9 сағат бұрын

    Bro if the question ask for 5 mark.. How much mark will get if i write this method🫠

  • @techdose4u
    @techdose4u4 сағат бұрын

    10. extra marks for making my life easy in checking 😂

  • @AyushKumar-kh8oh
    @AyushKumar-kh8oh11 сағат бұрын

    nice explanation

  • @boomer_mcghee
    @boomer_mcghee20 сағат бұрын

    i love you

  • @DeepakSingh-uf5vv
    @DeepakSingh-uf5vv20 сағат бұрын

    What if the array is made up of floats something like 0.76546, 2, 0.65, ....

  • @souravroychowdhury6525
    @souravroychowdhury652521 сағат бұрын

    amazing explanation !!

  • @techdose4u
    @techdose4u4 сағат бұрын

    Thanks

  • @tanzimchowdhury320
    @tanzimchowdhury320Күн бұрын

    Amazing, just amazing, after 4/5 videos, this is the only guy that makes sense!

  • @rohanrajput36940
    @rohanrajput36940Күн бұрын

    hates(mom,bua). 1:25

  • @rey22122
    @rey22122Күн бұрын

    makasih bang, besok aku exam jadi mengerti

  • @divinity8683
    @divinity8683Күн бұрын

  • @harshitsahu2704
    @harshitsahu2704Күн бұрын

    just awsome made my code just after first 3 min of viedo .

  • @love_for_cars__bikes
    @love_for_cars__bikesКүн бұрын

    Man you blew my mind 🤯🤯 Is this always this easy or am I the one who's tripping??

  • @abid3801
    @abid3801Күн бұрын

    you are Robot.

  • @thenepalinerd
    @thenepalinerdКүн бұрын

    if you r to merge the sorted chunk and again sort it, why the heck would you sort the chunk first... just merge everything and sort it there... your step is taking double the time. geez youtube ka 50 IQ ka instructor

  • @techdose4u
    @techdose4uКүн бұрын

    You can choose any inplace algorithm like heapsort. Then find sorted array with O(1) space and then write back the chunks in contiguous memory in the drive. That will effective be done in O(1) extra space and O(NlogN) time complexity.

  • @gayiii1911
    @gayiii1911Күн бұрын

    great explaination!

  • @techdose4u
    @techdose4uКүн бұрын

    thanks :)

  • @dharanish5816
    @dharanish58162 күн бұрын

    Today I have attended Zoho on campus drive.This question is asked in basic programming round💯.

  • @techdose4u
    @techdose4uКүн бұрын

    nice :)

  • @rahuldey5564
    @rahuldey55642 күн бұрын

    what is this algorithm called?

  • @techdose4u
    @techdose4u2 күн бұрын

    dutch national flag maybe :)

  • @Polly10189
    @Polly101893 күн бұрын

    Now I will not forget this, thanks

  • @techdose4u
    @techdose4u2 күн бұрын

    great

  • @tanishachoudhary2588
    @tanishachoudhary25883 күн бұрын

    this is the best video on articulation point, hats off to your comendable efforts 👑

  • @techdose4u
    @techdose4u2 күн бұрын

    thanks

  • @kushagrashekhawat8227
    @kushagrashekhawat82273 күн бұрын

    I've watched many of your videos. Your explanations are always very easy to understand. Thank you for creating these videos; you are doing so much good.

  • @techdose4u
    @techdose4u2 күн бұрын

    thanks :)

  • @user-wg5vc9ik1s
    @user-wg5vc9ik1s4 күн бұрын

    Why we are not moving i back to previous + 1 position?

  • @NishagAppu
    @NishagAppu4 күн бұрын

    thanku for explaining pre in and post order in such a easy way my 5 month class converted into 7mints🫡

  • @techdose4u
    @techdose4u2 күн бұрын

    woww :)

  • @sanoferniswan5901
    @sanoferniswan59014 күн бұрын

    Superb explanation ❤

  • @techdose4u
    @techdose4u2 күн бұрын

    thanks :)

  • @user-lj1ny6ts1f
    @user-lj1ny6ts1f4 күн бұрын

    Thank you 🎉🎉

  • @techdose4u
    @techdose4u2 күн бұрын

    welcome

  • @mathewsjose1990
    @mathewsjose19905 күн бұрын

    Nice explanation!

  • @techdose4u
    @techdose4u2 күн бұрын

    thanks

  • @user-wt2dq5yt9h
    @user-wt2dq5yt9h5 күн бұрын

    good explanation but I need to implement it using for loops not recursive functions (it is more complex)

  • @IdrisNirah
    @IdrisNirah5 күн бұрын

    Thanks

  • @techdose4u
    @techdose4u2 күн бұрын

    welcome

  • @pasumarthiashik1099
    @pasumarthiashik10995 күн бұрын

    perfect explanation

  • @techdose4u
    @techdose4u2 күн бұрын

    thanks

  • @anandpandey918
    @anandpandey9185 күн бұрын

    // Bruteforce Approach class Solution { public int subarraySum(int[] arr, int k) { int[] prefixSum = new int[arr.length]; for (int i = 0; i < arr.length; i++) { if (i == 0) { prefixSum[i] = arr[i]; } else { prefixSum[i] = prefixSum[i - 1] + arr[i]; } } int count = 0; for (int start = 0; start < arr.length; start++) { for (int end = start; end < arr.length; end++) { if (findSubarraySum(prefixSum, start, end) == k) { count++; } } } return count; } private int findSubarraySum(int[] prefixSum, int startIndex, int endIndex) { if (startIndex == 0) { return prefixSum[endIndex]; } return prefixSum[endIndex] - prefixSum[startIndex - 1]; } } // Better Approach class Solution { public int subarraySum(int[] arr, int k) { int count = 0; for (int start = 0; start < arr.length; start++) { int subArraySum = 0; for (int end = start; end < arr.length; end++) { subArraySum += arr[end]; if (subArraySum == k) { count++; } } } return count; } } //Optimal Approach class Solution { public int subarraySum(int[] arr, int k) { Map<Integer, Integer> sumFrequencyMap = new HashMap<>(); int count = 0, prefixSum = 0; for (int val : arr) { prefixSum += val; if (prefixSum == k) { count++; } if (sumFrequencyMap.containsKey(prefixSum - k)) { count += sumFrequencyMap.get(prefixSum - k); } sumFrequencyMap.put(prefixSum, sumFrequencyMap.getOrDefault(prefixSum, 0) + 1); } return count; } } /* int[] arr = {3, 0, 7 ,2 ,-3 ,1 ,4 ,2}; and k = 7 Let's break down the method's implicit check for all subarrays: Possible Subarrays and Their Sums: Subarrays starting from index 0: [3] : Sum = 3 [3, 0] : Sum = 3 [3, 0, 7] : Sum = 10 [3, 0, 7, 2] : Sum = 12 [3, 0, 7, 2, -3] : Sum= 9 [3, 0, 7, 2, -3 ,1] : Sum= 10 [3, 0, 7, 2, -3, 1, 4]: Sum= 14 [3, 0, 7, 2, -3, 1, 4 , 2]: Sum= 16 Subarrays starting from index 1: [0] : Sum = 0 [0, 7] : Sum = 7 [0, 7, 2] : Sum = 9 [0, 7, 2, -3] : Sum = 6 [0, 7, 2, -3, 1] : Sum = 7 [0, 7, 2, -3, 1, 4] : Sum = 11 [0, 7, 2, -3, 1, 4, 2] : Sum = 13 Subarrays starting from index 2: [7] : Sum = 7 [7, 2] : Sum = 9 [7, 2, -3] : Sum = 6 [7, 2, -3, 1] : Sum = 7 [7, 2, -3, 1, 4] : Sum = 15 [7, 2, -3, 1, 4 , 2] : Sum = 17 Subarrays starting from index 3: [2] : Sum = 2 [2, -3] : Sum = -1 [2, -3, 1] : Sum = 0 [2, -3, 1, 4] : Sum = 4 [2, -3, 1, 4, 2] : Sum = 6 Subarrays starting from index 4: [-3] : Sum = -3 [-3, 1] : Sum = -2 [-3, 1, 4] : Sum = 2 [-3, 1, 4, 2] : Sum = 4 Subarrays starting from index 5: [1] : Sum = 1 [1, 4] : Sum = 5 [1, 4, 2] : Sum = 7 Subarrays starting from index 6: [4] : Sum = 4 [4, 2] : Sum = 6 Subarrays starting from index 7: [2] : Sum = 2 Observation : In first iteration the direct lookup(for prefixSum= 3) is for subarray [3] (doesnot sum to 7) and map lookup(for repetition of (prefixSum-7) i.e -4) is for [] subarray, which does not sum to 7 so ignored. (Hence count=0 and Map:{3:1}) In second iteration the direct lookup(for prefixSum= 3) is for subarray [3 ,0] (doesnot sum to 7) and the map lookup (for repetition of (prefixSum-7) i.e -4) is for subarray [0] , which does not sum to 7 so ignored. (Hence count =0 and Map: {3:2}) In third iteration the direct lookup(for prefixSum= 10) is for subarray[3 ,0 ,7] (doesnot sum to 7) and the map lookup(for repetition of (prefixSum-7)= 3) is for subarrays [0, 7] and [7] , both of these subarrays sum to 7 so include it. (i.e count=0+1+1= 2 i.e [0, 7] and [7] and Map: {3:2,10:1}) In fourth iteration the the direct lookup(for prefixSum= 12) is for subarray [3 , 0, 7, 2] (doesnot sum to 7) and the map lookup (for repetition of (prefixSum-7)= 5) is for subarrays [0, 7, 2] , [7, 2] and [2] but none of these subarrays sum to 7 so ignored (i.e count=2 i.e i.e [0, 7] and [7] and Map: {3:2,10:1,12:1}) In fifth iteration the the direct lookup(for prefixSum= 9) is for subarray [3, 0, 7, 2, -3] (doesnot sum to 7) and the map lookup (for repetition of (prefixSum-7)= 2) is for subarrays [0, 7, 2, -3] , [7, 2, -3] and [2, -3] and [-3] but none of these subarray sum to 7 so ignored (i.e count=2 i.e [0, 7] and [7] and Map: {3:2,10:1,12:1,9:1}) In sixth iteration the the direct lookup(for prefixSum= 10) is for subarray [3, 0, 7, 2, -3 ,1] (doesnot sum to 7) and the map lookup (for repetition of (prefixSum-7)= 3) is for subarrays [0, 7, 2, -3, 1], [7, 2, -3, 1] and [2, -3, 1] and [-3, 1] , two of these subarray sum to 7 (i.e count=2+1+1=4 i.e [0, 7], [7], [0, 7, 2, -3, 1] and [7, 2, -3, 1] and Map: {3:2,10:2,12:1,9:1}) In seventh iteration the the direct lookup(for prefixSum= 14) is for subarray [3, 0, 7, 2, -3, 1, 4] (doesnot sum to 7) and the map lookup (for repetition of (prefixSum-7)= 7) is for subarrays [0, 7, 2, -3, 1, 4] , [7, 2, -3, 1, 4] , [2, -3, 1, 4] , [-3, 1, 4] , [1, 4] and [4] , None of these subarray sum to 7 (i.e count=4 i.e [0, 7] ,[7], [0, 7, 2, -3, 1] and [7, 2, -3, 1] and Map: {3:2,10:2,12:1,9:1,14:1}) In eight iteration the the direct lookup(for prefixSum= 16) is for subarray [3, 0, 7, 2, -3, 1, 4 , 2] (doesnot sum to 7) and the map lookup (for repetition of (prefixSum-7)= 9) is for subarrays [0, 7, 2, -3, 1, 4, 2] , [7, 2, -3, 1, 4 , 2] , [2, -3, 1, 4 , 2] , [-3, 1, 4, 2] , [1, 4, 2] , [4, 2] and [2] ,one of these subarray sum to 7 (i.e count=4 + 1 = 5 i.e [0, 7] ,[7], [0, 7, 2, -3, 1], [7, 2, -3, 1] and [1, 4, 2] and Map: {3:2,10:2,12:1,9:1,14:1,16:1}) */

  • @andresdallarizza1526
    @andresdallarizza15266 күн бұрын

    fucking legend lov u adore u

  • @techdose4u
    @techdose4u2 күн бұрын

    :)

  • @srivishnudeepika8097
    @srivishnudeepika80976 күн бұрын

    Such clear explanation and visual drawings are the reason why u r ny go to person for DSA , you are #1 man

  • @techdose4u
    @techdose4u6 күн бұрын

    thanks :)

  • @sanatani9273
    @sanatani92737 күн бұрын

    Well explained dude! 😂❤

  • @techdose4u
    @techdose4u2 күн бұрын

    thanks :)

  • @channadissanayaka6450
    @channadissanayaka64507 күн бұрын

    very clear explaination.

  • @techdose4u
    @techdose4u2 күн бұрын

    thanks :)

  • @n.h.son1902
    @n.h.son19027 күн бұрын

    I'm satisfied with the proof on the time complexity. What about the space complexity? May I ask why it is O(logN)?

  • @techdose4u
    @techdose4u7 күн бұрын

    log N is the height of the tree. we are building heap inplace

  • @amgadshrief7215
    @amgadshrief72158 күн бұрын

    you are awesome keep going bro

  • @techdose4u
    @techdose4u2 күн бұрын

    thanks :)

  • @channadissanayaka6450
    @channadissanayaka64508 күн бұрын

    Thank you ... This is very clear

  • @techdose4u
    @techdose4u2 күн бұрын

    thanks :)

  • @channadissanayaka6450
    @channadissanayaka64508 күн бұрын

    Thank you very much

  • @techdose4u
    @techdose4u2 күн бұрын

    welcome

  • @channadissanayaka6450
    @channadissanayaka64508 күн бұрын

    thank you very much

  • @techdose4u
    @techdose4u2 күн бұрын

    welcome

  • @channadissanayaka6450
    @channadissanayaka64508 күн бұрын

    thank you very much

  • @techdose4u
    @techdose4u2 күн бұрын

    welcome

  • @umarmasud2462
    @umarmasud24628 күн бұрын

    Thanks 😢❤

  • @techdose4u
    @techdose4u2 күн бұрын

    welcome :)

  • @greenhawk271
    @greenhawk2719 күн бұрын

    bhai ye to pta hi hota hai you need to find the ans without using inorder aise to bst ke saare que hote hi hai inorder se interview mai aise allowed nai krte

  • @QuynhNhu-gu5ql
    @QuynhNhu-gu5ql9 күн бұрын

    How to contact for you. I come to VIỆT NAM

  • @abhilashpatel3036
    @abhilashpatel30369 күн бұрын

    didn't notice new intro look. nice!

  • @melwinalm
    @melwinalm9 күн бұрын

    Such a great explanation

  • @techdose4u
    @techdose4u2 күн бұрын

    thanks :)

  • @DennisSimplifies
    @DennisSimplifies9 күн бұрын

    😂😂😂 bro simply too good 👍

  • @techdose4u
    @techdose4u2 күн бұрын

    :)

  • @space_ace7710
    @space_ace77109 күн бұрын

    Best explanation I found!

  • @techdose4u
    @techdose4u2 күн бұрын

    thanks :)

  • @MP-ny3ep
    @MP-ny3ep9 күн бұрын

    Great explanation. Thank you

  • @ventacode
    @ventacode9 күн бұрын

    here for daily solution bud !1

  • @techdose4u
    @techdose4u2 күн бұрын

    welcome :)

  • @jeevatrolls6184
    @jeevatrolls61849 күн бұрын

    Sir, where i can find the problems

  • @prasannakatabattini1974
    @prasannakatabattini19749 күн бұрын

    can u send the code for this problem..i got wrong an"Could you please provide the code for this problem? I received an incorrect answer." swer

  • @karthikeyank7467
    @karthikeyank746710 күн бұрын

    Best solution is still O(N)