Coin Change with Fewest Number of Coins Given Infinite Supply

Problem You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. You may assume that you have an infinite number of each kind of coin. ...

House Robber 1

Problem You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and it will automatically contact the police if two adjacent houses were broken into on the same night. Given an integer array nums representing the amount of money of each house, return the maximum amount of money you can rob tonight without alerting the police. ...

Word Break 1 - Check if word is breakable

Problem Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. Examples Example 1: Input: s = "leetcode", wordDict = ["leet","code"] Output: true Explanation: Return true because "leetcode" can be segmented as "leet code". Example 2: ...

Decode Ways Problem

Problem A message containing letters from A-Z can be encoded into numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 To decode an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For example, "11106" can be mapped into: ...

Subsets 2 Problem

Problem Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Examples Example 1: Input: nums = [1,2,2] Output: [ [],[1],[1,2],[1,2,2],[2],[2,2] ] Example 2: Input: nums = [0] Output: [ [],[0] ] ...

Edit Distance Problem

Problem Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations permitted on a word: Insert a character Delete a character Replace or substitute a character Examples Example 1: Input: word1 = "horse", word2 = "ros" Output: 3 Explanation: horse -> rorse (replace 'h' with 'r') rorse -> rose (remove 'r') rose -> ros (remove 'e') ...

Unique Paths in Grid 2 - Count all paths moving right or down with obstacles

Problem You are given an m x n integer array grid. There is a robot initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m-1][n-1]). The robot can only move either down or right at any point in time. An obstacle and space are marked as 1 or 0 respectively in grid. A path that the robot takes cannot include any square that is an obstacle. ...

Unique Paths in Grid 3 - Count all paths moving in 4 directions with obstacles and custom start and end

Problem You are given an m x n integer array grid where grid[i][j] could be: 1 representing the starting square. There is exactly one starting square. 2 representing the ending square. There is exactly one ending square. 0 representing empty squares we can walk over. -1 representing obstacles that we cannot walk over. Return the number of 4-directional walks from the starting square to the ending square, that walk over every non-obstacle square exactly once. ...

Best Time To Buy And Sell Stock 1 - only one transaction

Problem You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0. OR ...

Regular Expression Matching Problem

Problem Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where: '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). Examples Some examples: isMatch("aa","a") ? false isMatch("aa","a.") ? true isMatch("aaa","ab*") ? false isMatch("aa", ".*") ? true isMatch("aa", "a*") ? true isMatch("ab", ".*") ? true isMatch("aabaa", "a*b.*") ? false ...

This site uses cookies to improve your experience on our website. By using and continuing to navigate this website, you accept this. Privacy Policy