Sammith S Bharadwajsammith.hashnode.dev·Mar 18, 2024TIL but from tweets(I am the guy who can't implement breadth first search without googling)https://twitter.com/ronawang/status/1768337091312943575 Of course I cannot implement BFS without googling lol, not the smartest or sharpest but I can write an article about it though. What is BFS? BFS is a graph traversal algorithm to find the shor...DiscussPython 3
Kallol Bairagikallolbairagi.hashnode.dev·Oct 26, 2023#199.Binary Tree Right Side View [LeetCode Grind 75 in Java]class Solution { public List<Integer> rightSideView(TreeNode root) { ArrayList<Integer> ans = new ArrayList<>(); if(root == null) return ans; Queue<TreeNode> q = new LinkedList<>(); q.add(root); ans.add(r...DiscussLeetCode Grind 75 in JavaDSA
Kallol Bairagikallolbairagi.hashnode.dev·Oct 24, 2023#200.Number of Islands [LeetCode Grind 75 in Java]class Solution { private int[][] dir = {{1,0}, {-1,0}, {0,1}, {0,-1}}; public int numIslands(char[][] grid) { int r = grid.length; int c = grid[0].length; int numberIslands = 0; for(int i = 0; i < r; i ++){...DiscussLeetCode Grind 75 in JavaDSA
Kallol Bairagikallolbairagi.hashnode.dev·Oct 21, 2023#102.Binary Tree Level Order Traversal [LeetCode Grind 75 in Java]class Solution { public List<List<Integer>> levelOrder(TreeNode root) { List<List<Integer>> ans = new ArrayList<List<Integer>>(); Queue<TreeNode> queue = new LinkedList<>(); queue.add(root); if(root == null) retu...DiscussLeetCode Grind 75 in JavaDSA
Kallol Bairagikallolbairagi.hashnode.dev·Oct 21, 2023#542.01 Matrix [LeetCode Grind 75 in Java]class Solution { private int[][] dir = {{0,1}, {0,-1}, {1,0}, {-1,0}}; public int[][] updateMatrix(int[][] mat) { int r = mat.length; int c = mat[0].length; int MAX_VALUE = r*c; //treating mat as visted arrays as we...DiscussLeetCode Grind 75 in JavaJava
Kallol Bairagikallolbairagi.hashnode.dev·Oct 8, 2023#104.Maximum Depth of Binary Tree [LeetCode Grind 75 in Java]class Solution { public int maxDepth(TreeNode root) { if(root == null) return 0; //BFS traversal Queue<TreeNode> q = new LinkedList<TreeNode>(); q.add(root); int depth = 0; while(!q.isEmpty()){ ...DiscussLeetCode Grind 75 in JavaDSA
Anton Yarkovoptiklab.hashnode.dev·Sep 16, 2023Universal implementation of BFS, DFS, Dijkstra and A-Star algorithmsIt turns out that well-known algorithms like BFS, DFS, Dijkstra, and A-Star are essentially variations of the same algorithm. In other words, it is possible to implement a universal data structure that can switch between these algorithms without requ...Discuss·42 readsBFS
Uzmauzma.hashnode.dev·Jul 31, 2023Binary Search TreeA binary search tree (BST) is a binary tree in a symmetric order, where each node has a key (and an associated value). A binary tree means it consists of nodes, and each node has at most two children(left and right child). While being in a symmetric ...Discuss·1 likebinary search
Husain Shahid Raohusain3012.hashnode.dev·Jun 21, 2023Playing with the syntax - Functional programming with ElixirDisclaimer: I am learning the language myself, and in no way i am even close to being an expert, so consider this blog, as a journey diary, instead of a guide. What's this blog about? Getting used to short-hand syntax, and the pattern of writing code...Discuss·1 likeFunctional Programming
Haneunhanlee.hashnode.dev·May 2, 2023Mastering Graphs and Trees: Essential Concepts and Traversal Techniquespreorder = root left right DFS use stack = inorder= left root right postorder = left right root BFS use queue = print each level Graph Used to represent various real-world scenarios such as social networks, transportation systems, and computer netw...Discuss·27 readsProgrammingDFS