You are given an array of words where each word consists of lowercase English letters. word<sub>A</sub> is a predecessor of word<sub>B</sub> if and only if we can insert exactly one letter anywhere in word<sub>A</sub> without changing the order of th...
Dynamic programming (DP) is a problem-solving technique used to optimize decision-making by breaking complex problems into simpler subproblems, solving each subproblem only once, and storing their solutions for reuse. It leverages the properties of o...
Dynamic Programming (DP) is a powerful technique used to solve problems that involve making a sequence of decisions, often with overlapping sub problems. It’s widely regarded as a challenging concept, but with the right approach, it becomes a highly ...
Dynamic programming (DP) is a method for solving complex problems by breaking them down into simpler overlapping subproblems. It’s a favorite topic in Google interviews because it tests a candidate’s ability to recognize patterns and optimize naive s...
Problem https://leetcode.com/problems/shortest-common-supersequence/description/ Leetcode - Shortest Common Supersequence Type - Dynamic programming, String, LCS(Longest Common Subsequence) Difficulty - Hard Approach & Solution The worst case is stri...
Problem https://leetcode.com/problems/length-of-longest-fibonacci-subsequence/description/ Leetcode - Length of Longest Fibonacci Subsequence Type - Dynamic programming Difficulty - Medium Approach & Solution Let DP[prev][curr] is the length of Fibon...
Problem https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum/description/ Leetcode - Number of Sub-arrays With Odd Sum Type - Prefix Sum, Dynamic Programming Difficulty - Medium Approach && Solution Since the length of arr can be up to 10^...
Understanding the Problem There is a pyramid given with the length of n. From the bottom to top, the length of the floor is narrowed by 1. # input triangle = [[2],[3,4],[6,5,7],[4,1,8,3]] # output 11 # visualised triangle 2 3 4 6 5 7 4 1 8 3 ...
Recursive Solution class Solution { public int uniquePaths(int m, int n) { return countPath(m-1,n-1); } private int countPath(int i,int j){ if(i == 0 && j == 0)return 1; if(i < 0 || j < 0)return 0; int up ...
Artificial Intelligence (AI) Roadmap 1. Mathematics for AI Linear Algebra (Vectors, Matrices, Eigenvalues) Calculus (Derivatives, Partial Derivatives, Chain Rule) Probability & Statistics (Bayes’ Theorem, Distributions) Optimization (Gradient Des...