Photo by Robert Lukeman

Problem : Given two strings S and T. Consider taking a non-empty subsequence from S, a non-empty subsequence from T, and then concatenating the first subsequence with the second. Return the longest possible palindrome that can be constructed.

Let us consider an example to understand what we are required to do.


Photo by Sascha Bosshard

Problem : Given a binary tree root, return the top view of the tree, sorted left to right.

Let us consider an example to understand what we are required to do.


Photo by Ged Lawson

Problem: Given a 2-D list of integers containing 1s and 0s. Return a 2-D matrix representing the Manhattan distance of the current cell from the nearest 0 cell. It can be assumed that at least one 0 exists in the matrix.

Let us consider an example to understand what we are required to do.


Photo by Zane Lee

Problem: Given a binary tree, return the longest path that alternates, going down from one child to the other child. For example, it may alternate between right child, left child, right child, etc. Or left child, right child, left child, etc, going down.

Let us consider an example to understand the problem better,


Photo by Gautam Arora

Problem: Given the strings “A” and “B” consisting of lowercase alphabet characters, return the number of subsequences of “A” that are equal to “B”. Mod the result by 10**9 + 7.

Let us consider an example to understand the problem better,


Photo by Jaromír Kavan

Problem : You are given N cities represented as integers and a list of one-way roads that connects one city to another. Return whether you can reach one city from any city.

Let us consider an example to understand the problem better,


Photo by Chris J. Davis

Problem: Given a list of integers, arr. Consider a tree where arr represents the values of its leaves in an inorder traversal. All internal nodes have 2 children each and their value is equal to the product of the largest leaf value of its left subtree and the largest leaf value of its right subtree. Find the tree with the minimum sum of its values and return the sum.

Let us consider the following example to get a clearer idea of this problem,


Photo by Sergi Kabrera

Problem : Given a two-dimensional matrix of integers containing 1s and 0s, return the total number of square submatrices with all 1s.

Let us consider the following example to get a clearer idea of this problem,


Photo by Markus Winkler

In our previous blog, we already started with the introduction to one of the problems that we are going to discuss. We will try to discuss further about the topics involved.

Let us revisit the problem statement,

Problem #1: Given two strings A and B, find the minimum edit distance between the two strings. Edit distance is defined using: (a) Deleting a character, (b) Inserting a character, (c) Replacing a character.

Let us consider the following example to get a clearer idea of this problem,


Photo by Surface

In our previous blog, we already started with the introduction to one of the problems that we are going to discuss. We will try to discuss further about the topics involved.

Let us revisit the problem statement,

Problem #1: Given a binary tree, return the largest sum of any simple path between any two nodes.

This problem can be contemplated as an extension to finding the diameter of a binary tree problem.

Let us consider an example to understand what we are actually seeking,

Ankesh Krishna Prasad

Sport Programmer | Software Development Enthusiast | Problem Solver | Philonoist

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store