Ajinkya Jain

Ajinkya Jain

Пікірлер

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

    JAVA Code: public int editDistance(String str1, String str2) { // Code here int n = str1.length(); int m = str2.length(); int dp[][] = new int[n + 1][m + 1]; for(int[] arr : dp){ Arrays.fill(arr, -1); } return util(str1, str2, n, m, dp); } int util(String str1, String str2, int n, int m, int[][] dp){ if(n == 0){ return m; } if(m == 0){ return n; } if(dp[n][m] != -1){ return dp[n][m]; } if(str1.charAt(n - 1) == str2.charAt(m - 1)){ return dp[n][m] = util(str1, str2, n - 1, m - 1, dp); } return dp[n][m] = Math.min(util(str1, str2, n, m - 1, dp) + 1, Math.min(util(str1, str2, n - 1, m, dp) + 1, util(str1, str2, n - 1, m - 1, dp) + 1)); }

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

    C++ Code: int editDistanceUtil(const std::string& str1, const std::string& str2, int pos1, int pos2, std::vector<std::vector<int>>& dp) { if (pos1 == 0) { return pos2; } if (pos2 == 0) { return pos1; } if (dp[pos1][pos2] != -1) { return dp[pos1][pos2]; } if (str1[pos1 - 1] == str2[pos2 - 1]) { return dp[pos1][pos2] = editDistanceUtil(str1, str2, pos1 - 1, pos2 - 1, dp); } return dp[pos1][pos2] = std::min(editDistanceUtil(str1, str2, pos1 - 1, pos2, dp), std::min(editDistanceUtil(str1, str2, pos1, pos2 - 1, dp), editDistanceUtil(str1, str2, pos1 - 1, pos2 - 1, dp))) + 1; } int editDistance(const std::string& str1, const std::string& str2) { int m = str1.size(); int n = str2.size(); std::vector<std::vector<int>> dp(m + 1, std::vector<int>(n + 1, -1)); return editDistanceUtil(str1, str2, m, n, dp); }

  • @abdihaashin1350
    @abdihaashin135012 күн бұрын

    you talk too fast. talk slow

  • @selfsigma9764
    @selfsigma976422 күн бұрын

    nice code..thanks!!

  • @_arnav_chaudhuri
    @_arnav_chaudhuri22 күн бұрын

    crazy knowledge !!

  • @venumarsh3195
    @venumarsh319522 күн бұрын

    Great

  • @parameshkumar6580
    @parameshkumar658022 күн бұрын

    i too thought about similar approach but failed to implement it🙃.Thank you.

  • @bharatmittal1375
    @bharatmittal137523 күн бұрын

    Great approach. Appreciate it

  • @sachingaikwad5077
    @sachingaikwad507727 күн бұрын

    Clear and concise explanation.

  • @ajinkyajain2302
    @ajinkyajain230227 күн бұрын

    Glad you liked it

  • @Lawandorder0
    @Lawandorder02 ай бұрын

    thelogictutorial.blogspot.com/2024/05/find-pair-given-difference-17-may.html#google_vignette daily solution here

  • @ankurverma4042
    @ankurverma40422 ай бұрын

    sort(arr.begin(),arr.end()); int i = 0, j = 1; while (i < n && j < n) { int diff = abs(arr[j] - arr[i]); if (diff == x && i != j) { return 1; } else if (diff < x) { j++; } else { i++; } // Ensure i and j don't overlap incorrectly if (i == j) { j++; } } return -1; } This is the correct code the above code you have given is giving an error for the test case where n=10 and x=0 and the array is [1,2,3,4,5,6,7,8,9,10] when i and j are coming at the same place they are giving 0 but they cannot make a pair since they are the same number

  • @ajinkyajain2302
    @ajinkyajain23022 ай бұрын

    If you check the video we have taken care of that check in C++code. For Java, the tests are passing without the check.

  • @ajinkyajain2302
    @ajinkyajain23022 ай бұрын

    Also I have given the code links in the description.

  • @ankurverma4042
    @ankurverma40422 ай бұрын

    okay cool

  • @lakshya7089
    @lakshya70892 ай бұрын

    Bro I can give you cool looking obs setup for recording

  • @SparkSpirit-pq4qq
    @SparkSpirit-pq4qq3 ай бұрын

    Bro, Please make a videos for POTD in Gfg. your videos help me to improve my Programming skills as well as Getting idea to solve a POTD problems on gfg.

  • @nitby27
    @nitby274 ай бұрын

    sir the java code which you have provided in the github is not working

  • @ajinkyajain2302
    @ajinkyajain23024 ай бұрын

    Let me check.

  • @ajinkyajain2302
    @ajinkyajain23024 ай бұрын

    My bad, I have corrected the code on Github, please check, it should work.

  • @nitby27
    @nitby274 ай бұрын

    @@ajinkyajain2302 thank you

  • @Code_loading
    @Code_loading4 ай бұрын

    Sir my java code is not working it's not submitting

  • @ajinkyajain2302
    @ajinkyajain23024 ай бұрын

    Can you post your code here?

  • @Code_loading
    @Code_loading4 ай бұрын

    @@ajinkyajain2302 class Solution { public int ans=Integer.MAX_VALUE; public int absolute_diff(Node root) { int pre=-1; inorder(root,pre); return ans; } public void inorder(Node root,int pre){ if(root==null) return ; inorder(root.left,pre); if(pre!=-1) ans=Math.min(ans,Math.abs(root.data-pre)); pre=root.data; inorder(root.right,pre); } } when i submit this code in c++ it runs fine but java code showing error.

  • @jawa4098
    @jawa40984 ай бұрын

    @@ajinkyajain2302 class Solution { int prev = -1; int minAns = Integer.MAX_VALUE; public int absolute_diff(Node root) { // Call helper method to traverse the tree and calculate the minimum absolute difference helper(root); return minAns; } void helper(Node root) { if (root == null) { return; } // Traverse left subtree helper(root.left); // Update minAns if needed if (prev != -1) { minAns = Math.min(minAns, Math.abs(root.data - prev)); } prev = root.data; // Traverse right subtree helper(root.right); } } This code works fine

  • @ajinkyajain2302
    @ajinkyajain23024 ай бұрын

    My bad, I have corrected the code on Github, please check, it should work.

  • @anupamahalder4792
    @anupamahalder47924 ай бұрын

    Nice intuition helped a lot

  • @suryapratapsingh6801
    @suryapratapsingh68014 ай бұрын

    Thank you for the clear and concise explanation!

  • @jawa4098
    @jawa40984 ай бұрын

    Sir can you add gitHub link code for POTD always

  • @ajinkyajain2302
    @ajinkyajain23024 ай бұрын

    Yes, will keep this in mind, will share the Git hub link in sometime.

  • @jawa4098
    @jawa40984 ай бұрын

    @@ajinkyajain2302 Yeah you may forgot to add link in vid, no prob make a git repository for GFG POTD and upload ,so we will refer always there in repository, Thank you

  • @soundarr5828
    @soundarr58284 ай бұрын

    Thanks for the video sir. It was very helpful to understand and implement the solution.

  • @jawa4098
    @jawa40984 ай бұрын

    yeah wonderful , request you to add GitHub Link

  • @sanasainath7758
    @sanasainath77584 ай бұрын

    nice

  • @jawa4098
    @jawa40984 ай бұрын

    Great Teaching Skills Sir , could you add your java code gihub link in videos , it would great for us to develop our problem solving skills

  • @ajinkyajain2302
    @ajinkyajain23024 ай бұрын

    Noted. Will check on this! Thanks.

  • @gauravmishra1341
    @gauravmishra13414 ай бұрын

    thankyou sir

  • @abhishekdubey9920
    @abhishekdubey99204 ай бұрын

    Dark theme is must

  • @ajinkyajain2302
    @ajinkyajain23024 ай бұрын

    Thanks. Action taken!

  • @NKSmartWorld
    @NKSmartWorld4 ай бұрын

    Great sir

  • @parthbhatti4151
    @parthbhatti41515 ай бұрын

    Crystal Clear

  • @ThisIsPrince
    @ThisIsPrince5 ай бұрын

    Your video was really helpful🙌

  • @rohhittz
    @rohhittz5 ай бұрын

    Very nice explanation bro.! When encountering a problem, the approach taken by you to resolve the issue leads to a clearer understanding. Really helpful! Keep it up...

  • @ajinkyajain2302
    @ajinkyajain23025 ай бұрын

    Thanks 😊

  • @machans-203
    @machans-2035 ай бұрын

    In : [ab, bcd, b, a] , str = "abcd" Out : 1 Can u tell me, how this above input works in recursion In gfg , output is true, but my thought using this recursion it may be false. Can u explain me bro?

  • @garvitarora7777
    @garvitarora77775 ай бұрын

    it can be in any order . the second and fourth element made up the answer

  • @ajinkyajain2302
    @ajinkyajain23025 ай бұрын

    You got the answer explained in the above comment, or should I explain in detail? Let me know, thanks.

  • @machans-203
    @machans-2035 ай бұрын

    @@ajinkyajain2302 no bro, it's ok😁.. i find out how it's ok..

  • @AbhishekKumar-db5ec
    @AbhishekKumar-db5ec5 ай бұрын

    thanks

  • @vovanspictures9328
    @vovanspictures93286 ай бұрын

    brilliant as always! 👍

  • @vovanspictures9328
    @vovanspictures93286 ай бұрын

    it's better to use string as a key

  • @ajinkyajain2302
    @ajinkyajain23026 ай бұрын

    Yes this will work too for this problem, but it is not the most optimal solution, as storing strings will result in a lot of space consumption.

  • @rushabhlegion2560
    @rushabhlegion25606 ай бұрын

    Bro explanation samjha hi nhi. You were not trying to teach the intuition, you were just trying to explain the code.

  • @ajinkyajain2302
    @ajinkyajain23026 ай бұрын

    Hey buddy I would request you to watch the video again, Especially i think the first 5 minutes wherein I have explained the intuition (i.e. using prefix sum and remainder)

  • @raganaroak182
    @raganaroak1827 ай бұрын

    Best Solution || great explanation

  • @ajinkyajain2302
    @ajinkyajain23027 ай бұрын

    Thanks! Would also appreciate it if you subscribe to the channel(if not subscribed) this will motivate me 😊

  • @RohitKumar-us8my
    @RohitKumar-us8my7 ай бұрын

    for n =2 in same .. we will have k*k options? if we are choosing same colors then n1 has k options and n2 also has k options ?

  • @ajinkyajain2302
    @ajinkyajain23027 ай бұрын

    No.. it will have (k * 1) ways i.e. k ways only.. because as it will be the same colour scenario .. for the first fence it will take k ways(k colour choices).. and for the second fence it will have 1 way only(1 choice only as it will have to take the colour of the previous fence, it does not have the choice of selecting other colours), I hope it is clear.

  • @RohitKumar-us8my
    @RohitKumar-us8my7 ай бұрын

    @@ajinkyajain2302 understood.. thanks

  • @vovanspictures9328
    @vovanspictures93287 ай бұрын

    Thanks for video 👍

  • @ajinkyajain2302
    @ajinkyajain23027 ай бұрын

    Most Welcome 😊

  • @Bankai-kamishininoyari
    @Bankai-kamishininoyari8 ай бұрын

    thanks for the O(1) approach explained very beautifully

  • @ajinkyajain2302
    @ajinkyajain23028 ай бұрын

    Glad you liked it!

  • @andressaavelar9910
    @andressaavelar9910 Жыл бұрын

    Ajinkya Jain fiz os mesmos procedimentos que vc e apareceu me isto: ERR_CONNECTION_REFUSED. ja tentei varias formas de resolver como alteracao do zeppelin-0.10.1-bin-all para outras versoes, desativei e reinstalei o chrome, varios videos e stackoverflow com solucoes diferentes, mas ainda nada! Podes dar-me uma dica por favor?

  • @andressaavelar9910
    @andressaavelar9910 Жыл бұрын

    ahhhhhhhh que lindo! obrigada pelo video, ajudou me bastante :D

  • @rahulgoswami1161
    @rahulgoswami1161 Жыл бұрын

    Great explanation!!! Could you please do the same in app insight in place of creating local log!

  • @shikhajain4554
    @shikhajain4554 Жыл бұрын

    Nice explanation. Thanks

  • @ajaynikalje3857
    @ajaynikalje3857 Жыл бұрын

    Nice explanation... It saved my day ..

  • @RPATechnology22
    @RPATechnology222 жыл бұрын

    thank you brother for explanation

  • @lxtelxte8614
    @lxtelxte86142 жыл бұрын

    hello can I use zeppelin with python, pls help

  • @tugrulgokce
    @tugrulgokce2 жыл бұрын

    How to install Python Libraries in Apache Zeppelin.When ı run ipynb file then I am facing ModuleNotFoundError: No module named 'findspark'.

  • @wyattmeehan825
    @wyattmeehan8252 жыл бұрын

    Thank you!

  • @niteshhebbare3339
    @niteshhebbare33393 жыл бұрын

    Thanks sir! Keep up the good work