The Longest Increasing Subsequence (LIS) problem is to find the length of the longest subsequence of a given sequence such that all elements of the subsequence are sorted in increasing order.
Note: The subsequence is not necessarily unique or contiguous.
In this post, I'll be solving classic DP problem which involves finding lis of a given array as well as some of its variations.
The problems...
Leetcode 72. Edit Distance
Problem Link : https://leetcode.com/problems/edit-distance/
Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2.
You have the following 3 operations permitted on a word:
Insert a character
Delete a character
Replace a character
Example 1:
Input: word1 = "horse", word2 = "ros"
Output: 3
Explanation:
horse...
Leetcode 931. Minimum Falling Path Sum
Problem Link: https://leetcode.com/problems/minimum-falling-path-sum/
Given a square array of integers A, we want the minimum sum of a falling path through A.
A falling path starts at any element in the first row, and chooses one element from each row. The next row's choice must be in a column that is different from the previous row's column...
Leetcode 198. House Robber
Problem Link https://leetcode.com/problems/house-robber/
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 system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.
Given...
Leetcode 63. Unique Paths II
Problem Link: https://leetcode.com/problems/unique-paths-ii/
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right...
Leetcode 62: Unique Paths
Problem Link: https://leetcode.com/problems/unique-paths/
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right...
Python Data Structures 101: 1. How to LIST??
In this post, I'm going to talk about the list, one of the most common but powerful data structures in Python. Let's get started.
Q1. What is a python list?
Ans: List is a part of core Python Language. It is implemented as a dynamic array. It is heterogeneous(can hold elements of different data types) and is mutable unlike string and tuples in Python.
Q2. How to declare a list?
Ans: We can...