shashCode
shashCode
  • 522
  • 1 210 216
1905. Count Sub Islands | graphs | Leetcode Daily Challenge | DSA | Hindi
Number of Islands:
ua-cam.com/video/mwsuv-S1biw/v-deo.htmlsi=G1YDo-wyHLOZloie
Problem Name:
1905. Count Sub Islands
Problem Statement:
You are given two m x n binary matrices grid1 and grid2 containing only 0's (representing water) and 1's (representing land). An island is a group of 1's connected 4-directionally (horizontal or vertical). Any cells outside of the grid are considered water cells.
An island in grid2 is considered a sub-island if there is an island in grid1 that contains all the cells that make up this island in grid2.
Return the number of islands in grid2 that are considered sub-islands.
Problem Link:
leetcode.com/problems/count-sub-islands/description/?envType=daily-question&envId=2024-08-28
Solution Link:
github.com/Tiwarishashwat/InterviewCodes/blob/main/CountSubIsIland.java
Graph Playlist:
ua-cam.com/play/PLQ7ZAf76c0ZOGuMjg3qwNgILb_dKWTxyQ.html
Java Plus DSA Placement Course Playlist:
ua-cam.com/play/PLQ7ZAf76c0ZPVdhV1bAjFv0bQc1xHURzE.html
Java Plus DSA Sheet:
docs.google.com/spreadsheets/d/119u25NO-4ZJ9zwfUKs5eGNo0exCVq3gZEFWvkCDiMqI/edit?usp=sharing
Notes:
github.com/Tiwarishashwat/Java-Plus-DSA-Placement-Course
Telegram Link:
shashwattiwari.page.link/telegramShashwat
Ultimate Recursion Series Playlist:
ua-cam.com/play/PLQ7ZAf76c0ZMzC9OHPbo-dUgx6oU3T0jK.html
Instagram Handle: (@shashwat_tiwari_st)
shashwattiwari.page.link/shashwatInsta
Samsung Interview Experience:
ua-cam.com/video/GrvlpBzphSU/v-deo.html
Company Tags:
Facebook | Amazon | Microsoft | Netflix | Google | LinkedIn | Pega Systems | VMware | Adobe | Samsung
Timestamp:
0:00 - Introduction
#ShashwatTiwari #coding​​ #problemsolving​
Переглядів: 140

Відео

1514. Path with Maximum Probability | graphs | Bellmanford | Leetcode Daily Challenge | DSA | Hindi
Переглядів 1,4 тис.2 години тому
Problem Name: 1514. Path with Maximum Probability Problem Statement: You are given an undirected weighted graph of n nodes (0-indexed), represented by an edge list where edges[i] = [a, b] is an undirected edge connecting the nodes a and b with a probability of success of traversing that edge succProb[i]. Given two nodes start and end, find the path with the maximum probability of success to go ...
590. N-ary Tree Postorder Traversal | trees | Leetcode Daily Challenge | DSA | Hindi
Переглядів 2,1 тис.4 години тому
Problem Name: 590. N-ary Tree Postorder Traversal Problem Statement: Given the root of an n-ary tree, return the postorder traversal of its nodes' values. Nary-Tree input serialization is represented in their level order traversal. Each group of children is separated by the null value (See examples) Problem Link: leetcode.com/problems/n-ary-tree-postorder-traversal/description/?envType=daily-qu...
145. Binary Tree Postorder Traversal | trees | dfs | Leetcode Daily Challenge | DSA | Hindi
Переглядів 1,2 тис.7 годин тому
Iterative Postorder traversal: ua-cam.com/video/xEPe6aWlRd0/v-deo.htmlsi=zEBSlBGBvFqZI3tu Problem Name: 145. Binary Tree Postorder Traversal Problem Statement: Given the root of a binary tree, return the postorder traversal of its nodes' values. Problem Link: leetcode.com/problems/binary-tree-postorder-traversal/description/?envType=daily-question&envId=2024-08-25 Graph Playlist: ua-cam.com/pla...
564. Find the Closest Palindrome | maths | strings | Leetcode Daily Challenge | DSA | Hindi
Переглядів 2,9 тис.9 годин тому
Problem Name: 564. Find the Closest Palindrome Problem Statement: Given a string n representing an integer, return the closest integer (not including itself), which is a palindrome. If there is a tie, return the smaller one. The closest is defined as the absolute difference minimized between two integers. Problem Link: leetcode.com/problems/find-the-closest-palindrome/description/?envType=daily...
592. Fraction Addition and Subtraction | maths | strings | Leetcode Daily Challenge | DSA | Hindi
Переглядів 2,5 тис.12 годин тому
Problem Name: 592. Fraction Addition and Subtraction Problem Statement: Given a string expression representing an expression of fraction addition and subtraction, return the calculation result in string format. The final result should be an irreducible fraction. If your final result is an integer, change it to the format of a fraction that has a denominator 1. So in this case, 2 should be conve...
476. Number Complement | Bit Manipulation | Leetcode Daily Challenge | DSA | Hindi
Переглядів 1,7 тис.14 годин тому
Problem Name: 476. Number Complement Problem Statement: The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation. For example, The integer 5 is "101" in binary and its complement is "010" which is the integer 2. Given an integer num, return its complement. Problem Link: leetcode.com/problems/number-complement/descri...
Lecture-13 | 1443. Minimum Time to Collect All Apples in a Tree | leetcode | DSA | Hindi
Переглядів 360День тому
Problem Name: 1443. Minimum Time to Collect All Apples in a Tree Problem Statement: Given an undirected tree consisting of n vertices numbered from 0 to n-1, which has some apples in their vertices. You spend 1 second to walk over one edge of the tree. Return the minimum time in seconds you have to spend to collect all apples in the tree, starting at vertex 0 and coming back to this vertex. The...
Lecture-14 | 947. Most Stones Removed with Same Row or Column | Graphs | Leetcode | DSA | Hindi
Переглядів 13914 днів тому
Problem Name: 947. Most Stones Removed with Same Row or Column Problem Statement: On a 2D plane, we place n stones at some integer coordinate points. Each coordinate point may have at most one stone. A stone can be removed if it shares either the same row or the same column as another stone that has not been removed. Given an array stones of length n where stones[i] = [xi, yi] represents the lo...
Lecture-12 994. Rotting Oranges | BFS | Graphs| Leetcode | DSA | Hindi
Переглядів 14014 днів тому
Problem Name: 994. Rotting Oranges Problem Statement: You are given an m x n grid where each cell can have one of three values: 0 representing an empty cell, 1 representing a fresh orange, or 2 representing a rotten orange. Every minute, any fresh orange that is 4-directionally adjacent to a rotten orange becomes rotten. Return the minimum number of minutes that must elapse until no cell has a ...
Lecture-11 | 1311. Get Watched Videos by Your Friends | Graphs | Leetcode | DSA | Hindi
Переглядів 14914 днів тому
Problem Name: 1311. Get Watched Videos by Your Friends Problem Statement: There are n people, each person has a unique id between 0 and n-1. Given the arrays watchedVideos and friends, where watchedVideos[i] and friends[i] contain the list of watched videos and the list of friends respectively for the person with id = i. Level 1 of videos are all watched videos by your friends, level 2 of video...
Lecture - 15 | 721. Accounts Merge | graphs | Leetcode Daily Challenge | DSA | Hindi
Переглядів 17514 днів тому
Problem Name: 721. Accounts Merge Problem Statement: Given a list of accounts where each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails representing emails of the account. Now, we would like to merge these accounts. Two accounts definitely belong to the same person if there is some common email to both accounts...
703. Kth Largest Element in a Stream | Leetcode Daily Challenge | DSA | Hindi
Переглядів 3,3 тис.14 днів тому
Problem Name: 703. Kth Largest Element in a Stream Problem Statement: Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. Implement KthLargest class: KthLargest(int k, int[] nums) Initializes the object with the integer k and the stream of integers nums. int add(int val) Appends the integer val to...
959. Regions Cut By Slashes | graphs | Leetcode Daily Challenge | DSA | Hindi
Переглядів 2,8 тис.14 днів тому
Problem Name: 959. Regions Cut By Slashes Problem Statement: An n x n grid is composed of 1 x 1 squares where each 1 x 1 square consists of a '/', '\', or blank space ' '. These characters divide the square into contiguous regions. Given the grid grid represented as a string array, return the number of regions. Note that backslash characters are escaped, so a '\' is represented as '\\'. Problem...
840. Magic Squares In Grid | Leetcode Daily Challenge | DSA | Hindi
Переглядів 4,8 тис.14 днів тому
840. Magic Squares In Grid | Leetcode Daily Challenge | DSA | Hindi
885. Spiral Matrix III | matrix | Leetcode Daily Challenge | DSA | Hindi
Переглядів 4,3 тис.14 днів тому
885. Spiral Matrix III | matrix | Leetcode Daily Challenge | DSA | Hindi
273. Integer to English Words | Leetcode Daily Challenge | DSA | Hindi
Переглядів 4,9 тис.21 день тому
273. Integer to English Words | Leetcode Daily Challenge | DSA | Hindi
3016. Minimum Number of Pushes to Type Word II | Leetcode Daily Challenge | DSA | Hindi
Переглядів 3,4 тис.21 день тому
3016. Minimum Number of Pushes to Type Word II | Leetcode Daily Challenge | DSA | Hindi
2053. Kth Distinct String in an Array | string | Leetcode Daily Challenge | DSA | Hindi
Переглядів 2,2 тис.21 день тому
2053. Kth Distinct String in an Array | string | Leetcode Daily Challenge | DSA | Hindi
Range Sum of Sorted Subarray Sums | Priority Queue | Leetcode Daily Challenge | DSA | Hindi
Переглядів 2,2 тис.21 день тому
Range Sum of Sorted Subarray Sums | Priority Queue | Leetcode Daily Challenge | DSA | Hindi
1460. Make Two Arrays Equal by Reversing Subarrays | Leetcode Daily Challenge | DSA | Hindi
Переглядів 1,4 тис.21 день тому
1460. Make Two Arrays Equal by Reversing Subarrays | Leetcode Daily Challenge | DSA | Hindi
2134. Minimum Swaps to Group All 1's Together II | sliding window | Leetcode Daily Challenge | DSA
Переглядів 3,2 тис.21 день тому
2134. Minimum Swaps to Group All 1's Together II | sliding window | Leetcode Daily Challenge | DSA
2678. Number of Senior Citizens | String Manipulation | Leetcode Daily Challenge | DSA | Hindi
Переглядів 1,7 тис.21 день тому
2678. Number of Senior Citizens | String Manipulation | Leetcode Daily Challenge | DSA | Hindi
1105. Filling Bookcase Shelves | DP | Leetcode Daily Challenge | DSA | Hindi
Переглядів 3 тис.28 днів тому
1105. Filling Bookcase Shelves | DP | Leetcode Daily Challenge | DSA | Hindi
1653. Minimum Deletions to Make String Balanced | pre-computation | Leetcode Daily | DSA | Hindi
Переглядів 1,5 тис.28 днів тому
1653. Minimum Deletions to Make String Balanced | pre-computation | Leetcode Daily | DSA | Hindi
1395. Count Number of Teams | greedy | maths | Leetcode Daily Challenge | DSA | Hindi
Переглядів 2,4 тис.28 днів тому
1395. Count Number of Teams | greedy | maths | Leetcode Daily Challenge | DSA | Hindi
2045. Second Minimum Time to Reach Destination | graph | Leetcode Daily Challenge | DSA | Hindi
Переглядів 1 тис.28 днів тому
2045. Second Minimum Time to Reach Destination | graph | Leetcode Daily Challenge | DSA | Hindi
2976. Minimum Cost to Convert String I | graph | Leetcode Daily Challenge | DSA | Hindi
Переглядів 723Місяць тому
2976. Minimum Cost to Convert String I | graph | Leetcode Daily Challenge | DSA | Hindi
1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance | Leetcode | DSA
Переглядів 569Місяць тому
1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance | Leetcode | DSA
Floyd Warshall Algorithm | Shortest Path in Graph | GFG | DSA | Hindi
Переглядів 334Місяць тому
Floyd Warshall Algorithm | Shortest Path in Graph | GFG | DSA | Hindi

КОМЕНТАРІ

  • @spandansahu
    @spandansahu 38 хвилин тому

    when will the cycle detection in graph vdos be released?

  • @user-oi5ls4rs5g
    @user-oi5ls4rs5g Годину тому

    osm explain

  • @PiyushSharma-we8yd
    @PiyushSharma-we8yd 2 години тому

    first again🤩🤩🤩

  • @shashwat_tiwari_st
    @shashwat_tiwari_st 2 години тому

    Like target for this video is 120, please do like. Aaj ka question ban gaya hoga na? koi aur approach use kri hai toh share kro!! 😄

  • @user-hl2ix4ev7u
    @user-hl2ix4ev7u 16 годин тому

    In worst case ..why it does not give TLE because 2<=n<=1e4 and 0<=edges_length <=2*1e4??

  • @liki_raju
    @liki_raju 17 годин тому

    what is that 'V" that you used to define the variable prob of type double, moreover it is not pre-defined please check

    • @shashwat_tiwari_st
      @shashwat_tiwari_st 17 годин тому

      @@liki_raju ya I have corrected it in video before submission, it should be n, (total number of vertices)

  • @Pinncle-l2m
    @Pinncle-l2m 23 години тому

    bhaiya itna sab kara rahe to DP ka bhi thoda sochiye na please

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

    amazing approach. so simple and easy to understand. I used the same approach in the first try but then tried to solve it using dijkstra when i saw the hints in the question. Anyways, Kuddos

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

    Using HashMap sol : -> ✅LeetCode:- class Solution { public String replaceWords(List<String> dictionary, String sentence) { HashSet<String> set = new HashSet<>(); for(String s : dictionary){ set.add(s); } String[]wordsArr = sentence.split(" "); StringBuilder sb = new StringBuilder(); for(String currWord : wordsArr){ String replaceWord = currWord; for(int i = 0;i<currWord.length();i++){ String prefix = currWord.substring(0, i+1); if(set.contains(prefix)){ replaceWord = prefix; break; } } sb.append(replaceWord).append(" "); } return sb.toString().trim(); } }

  • @ShubhamSharma-sf8wk
    @ShubhamSharma-sf8wk День тому

    Can we have a separate detailed video for Bellman ford? This video feels rushed

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

      Ya I have not explained bellmanford in this video, By tomorrow evening you will get bellmanford algo..

    • @ShubhamSharma-sf8wk
      @ShubhamSharma-sf8wk 19 годин тому

      @@shashwat_tiwari_st You're the man, no other youtuber does this

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

    you make us understand every problem very easily...

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

    like target for this video is 100, please do like if you have understood😃

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

    Amazing content

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

    Great , love from jadavpur uni

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

    Sir iska Notes nhi h ?

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

    please add c++ too.

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

    Sir we want iteratively method by stack and deque . Plzzz

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

    Sir when are you releasing DP Series. Eagarly waiting ! Can we expect it around mid of September

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

    Sir your graph series is amazing one of the best creator but if you upload videos like a day in life of samsung developer then reach zyada rate se increase hogi I don't know right or wrong but this is my opinion

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

    easiest explaination thank you so much sirr

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

    Happy Janmashtami😄

  • @117_mainakpaul2
    @117_mainakpaul2 2 дні тому

    Can you have playlist of array coding of leetcode from beginners to pro ? Plz let me know

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

    Like target is 100, Please do like if you have understood the explanation!

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

    how space complexity is n-k ,could you please explain in detail ?

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

      the above question is for brut force approach.

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

    ok bhaiya watching iterative method also :")

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

    c++ class Solution { public: //week 13 void postorderTraversalHelper(TreeNode* root, vector<int>& ans) { if(root == NULL) return; else { //L postorderTraversalHelper(root->left, ans); //R postorderTraversalHelper(root->right, ans); //N ans.push_back(root->val); } } vector<int> postorderTraversal(TreeNode* root) { //postorderTraversal -> LRN //we will solve this using recurssion vector<int> ans; //we will use a helper function postorderTraversalHelper(root, ans); return ans; } };

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

    2 Homework In Java, a String is both a data type and a class. String as a Class: It belongs to java.lang.String and provides various methods to manipulate text. String as a Data Type: It represents a sequence of characters and is a reference data type in Java.

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

    Day 2 Lecture 4 Complated✅

  • @RishabhChatterjee-fg2gz
    @RishabhChatterjee-fg2gz 3 дні тому

    Bhaiya mein morris traversal se kiya

  • @PiyushSharma-we8yd
    @PiyushSharma-we8yd 3 дні тому

    ban gaya tha aaj, special thanks to your EPIC Tree Series😍

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

    Please do like this video, Like target for this video is 120. Please do watch iterative approach as well!

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

    awesome explanation bhaiya

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

    awesome thanks

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

    Great Explanation!

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

    I try this question by mySelf pass : 37/217 then for which testcase it's failed i fixed that but the code gives me TLE. Please somebody help me to fixed my code. #Code_is_given_below--> ```class Solution { public String nearestPalindromic(String n) { int mindif = Integer.MAX_VALUE; int num = Integer.parseInt(n); if(num == 1){return "0";} if(num >= 2 && num <= 10){ return Integer.toString(num - 1) ; } int ans = 0; //this is for the nearest palindrom bellow given "n" ex - > 123 for (int i = 1; i < num; i++) { if (isPalindrom(i)) { int currDif = num - i; if (currDif < mindif) { mindif = currDif; ans = i; } // break; } } //for this type of test case give error - > "1213" output ->"1221" for(int i = num+1; ;i++){ if(isPalindrom(i)){ int currDif = i - num; if(currDif < mindif){ ans = i; // get the first palindrome given number and stop there. } break; } } return Integer.toString(ans); } public boolean isPalindrom(int n){ int org = n; int rev = 0; while(n>0){ int lastdig = n%10; rev = (rev*10) + lastdig; n = n/10; } return (org != rev) ? false : true; } }```

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

    New to DSA concept your video is very helpful bhaiya❤

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

    ❤❤❤

  • @RishabhChatterjee-fg2gz
    @RishabhChatterjee-fg2gz 3 дні тому

    Bhaiya mere dimag mein pehele aaya tha, ki given string ko number mein convert koro, uske band do variable create Kara, ek given num - 1 and dusre given num + 1, and create a function to check palindrome, and call for both numbers, if both are palindrome then return minimum else return that number which is palindrome among both I know that it is ghatia approach, can anyone thought about this also? Please say

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

      Maine socha tha, but constraints dekh kr TLE hi laga toh try ni kra

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

    Bahot hi hard tha per ye video dekh ke samj me aa gaya .

  • @NiteshKumar-xm3nq
    @NiteshKumar-xm3nq 3 дні тому

    thankyou sir ,but please come up with examples that are not there in editorial... like 2002,11011....etc this will help us more .

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

    thanks G

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

    Animal is a class and cat ,dog , lion is an Object 🙂

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

    Subha 8 baje Baitha tha ye qs solve karne ke liye abhi solve hua khudse Almost 12 hr 😂 😂😢

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

    NICE SUPER EXCELLENT MOTIVATED

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

    shashwat Bhaia tum Aage badho Hum tumare sath Hai.....

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

    public String nearestPalindromic(String n){ long num=Long.valueOf(n); long small=smallest(String.valueOf(num-1)); long large=largest(String.valueOf(num+1)); if(large-num<num-small) return String.valueOf(large); else return String.valueOf(small); } private long largest(String n){ char[]c=n.toCharArray (); int s=0,e=c.length-1; while(s<e){ while(c[s]!=c[e]){ incrementNum(c,end); } s++;e--; } return Long.parseLong(String.valueOf(c)); } private long smallest(String n){ char[]c=n.toCharArray(); int s=0,e=c.length-1; while(s<e){ while(c[s]!=c[e]){ decrementNum(c,end); if(c[0]=='0') return Long.parseLong(String.valueOf(c)); } s++;e--; } return Long.parseLong(String.valueOf(c)); } private void decrementNum(char[]c,int i){ while(c[i]=='0'){ c[i]='9'; i--; } c[i]--; } private void incrementNum(char[]c,int i){ while(c[i]=='9'){ c[i]='0'; i--; } c[i]++; } } 🎉❤

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

    mene jab logic lagaya to run bhi hogya lekin test cases failed, par jab ye video dekha tab laga ye isliye HARD TAG tha😅😝

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

    TQ sir aapne bhut ache se samjhaya ❤

  • @PiyushSharma-we8yd
    @PiyushSharma-we8yd 3 дні тому

    tagra question tha bhaiya, maza aa gya 😍😍

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

      Log ro rhe hai 🤣 tmhe maza aa gya, waise strings manipulation toh mra bhi fav topic h

  • @shashwat_tiwari_st
    @shashwat_tiwari_st 4 дні тому

    little correction, we are using an arraylist of size 5, so although space is as good as constant but still you can mention it.