Problem tc :O(n) where n is no. of nodes in the original linked list Iterative approach: /* //...
Problem tc :O(n), sc:O(1) /* class Node{ int data; Node next; Node(int x){ ...
Problem Backtracking solution (TLE) tc : O(2^n) class Solution { List<Integer> result ...
Problem Same as : Next greater element than the stack top class Solution { public int[]...
O(n) : where n is no. of nodes Problem /* Definition for a Node. class Node { public int val; ...
Problem TC: O(n*4alpha) class Solution { public int[] minimumCost(int n, int[][] edges,...
Problem TC: O(n), SC: O(n) /** * Definition for a binary tree node. * public class TreeNode { ...
Problem TC: O(nlog(k)), where k is the max time in the range between 1 to r*n^2 class Solution { ...
Problem TC: O(nlog(Max(nums))) class Solution { public int minCapability(int[] nums, int k)...
Problem //same as coco eating bananas, //capacity to ship packages within d days //aggresive...
Problem Pattern: number of subarray/substring with condition like sum ==k or count = k TC:...
Find missing number class Solution { public int missingNumber(int[] nums) { //circular...
Problem TC: O(n*m) class Solution { public List<Integer> spiralOrder(int[][] matrix) { ...
Problem class WordDictionary { Trie t; public WordDictionary() { t = new Trie(); ...
Problem TC: O(n) SC: O(n) class Solution { public long gridGame(int[][] grid) { long...
Problem TC: O(n) SC:O(n) class Solution { public int subarraySum(int[] nums) { int...
TC:O(n*mlog(n*m)) SC :O(n*m) Problem //BFS : dijkstra's class Solution { public int...
Problem TC:O(n*m) SC:O(n*m) import java.util.* ; import java.io.*; class Pair<T> { T...
Problem TC : O(n*mlog(n*m)) SC: O(n*m) //BFS approach (dijkstra's algorithm) class Triple{ ...
Problem Same as Minimum Obstacle removal to reach corner Time Complexity: O(n*mlog(n*m) Space...
Problem Statement: Count Stars Between Pipes Problem Description You are given...
Problem TC : (n+m) where n and m are no. of bits in num1 and num2 respectively /* use...
Count prefix and suffix I Brute force approach: TC: O(n^2*m), n is words.length and m is the...
Problem TC:O(n) and SC: O(n) // using rabin karp hashing approach class Solution { public...
Problem This is similar to Product of array except self TC: O(n) ,SC:O(n) # this is same as...
Problem TC:O(n) SC:(k) is no. of substrings(anagrams) + O(1) for using constant space array of size...
Problem TC: O(n) for calculating prefix sum, and O(n) for iterating over the prefix sum for...
Problem TC: O(n*m) for creating the prefix[][] sum matrix, O(row1+row2) for calculating the sum of...
Problem TC: O(n) for calculating the prefix[] and O(k) for getting all the counts of the vowels in...
Problem TC: O(n) for calculating the prefix sum and O(1) for getting the sum of the subarray in the...