ProDeveloperTutorialonAugust 31, 2026 Two Pointers: Given an array and a value “m”, choose “m” elements having minimum difference between max and min Problem Statement: You are given an array and a value “m”. You need to pick exactly m elements such that the difference between…
ProDeveloperTutorialonAugust 31, 2026 Greedy: Given a string, check if it is a valid parenthesis or not Problem Statement: You are given a string having only “(“, “)”, “*”. Return true if its a valid…
ProDeveloperTutorialonAugust 31, 2026 Greedy: Given a string, return the length of longest palindrome Problem Statement: Given a string, return the length of longest palindrome substring that can be constructed with those letters Palindrome are…
ProDeveloperTutorialonAugust 31, 2026 Greedy: Given a number and a value k, return the smallest digit after removing k digits Problem Statement: Given a number and a value k, return the smallest digit after removing k digits Example: Input: num = "12345" k =…
ProDeveloperTutorialonAugust 31, 2026 Greedy: Given an array and a value k, check if we can have k consecutive numbers Problem Statement: Given an array and a value k, check if we can have k consecutive numbers Example: Input: arr = [1, 2, 3, 4, 5, 6, 7, 8] k =…
ProDeveloperTutorialonAugust 31, 2026 Greedy: Get the maximum number by swapping once Problem Statement: Given a number, you need to swap 2 digits to make the maximum value of the number. Example: Input num = 1234 Output: 4231…
ProDeveloperTutorialonAugust 31, 2026 Greedy: Check if a given string becomes palindrome by deleting atmost one char Problem Statement: You are given a string and you need to return true if the string is palindrome, by deleting at most one character. Example:…
ProDeveloperTutorialonAugust 31, 2026 Greedy: Given an array, find the longest alternative subsequence Problem Statement: You are given an array, you need to find the longest alternative sub-sequence. Alternative sub-sequence is a sequence where…
ProDeveloperTutorialonAugust 31, 2026 Greedy: Given a string, partition the string such that each letter appears at only one part Problem Statement: You are given a string, you need to partition in such a way that each letter appears at most one part. Example: Input str =…
ProDeveloperTutorialonAugust 31, 2026 Greedy: Check for Increasing triplet subsequence Problem Statement: You are given an array, you need to return true, if there is triplet in increasing subsequence. Example: Input: arr = [1,…