Shortest Common Supersequence in Python

Given two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences.  If multiple answers exist, you may return any of them. (A string S is a subsequence of string T if deleting some number of characters from T (possibly 0, and the characters are chosen anywhere from T) results in the string … Read more Shortest Common Supersequence in Python


Day of the Week in Python

Given a date, return the corresponding day of the week for that date. The input is given as three integers representing the day, month and year respectively. Return the answer as one of the following values {“Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”}. Example 1: Input: day = 31, month = 8, year = 2019 Output: … Read more Day of the Week in Python


Maximum Subarray Sum with One Deletion in Python

Given an array of integers, return the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion. In other words, you want to choose a subarray and optionally delete one element from it so that there is still at least one element left and the sum of the remaining elements is maximum possible. Note … Read more Maximum Subarray Sum with One Deletion in Python


Reverse Substrings Between Each Pair of Parentheses in Python

You are given a string s that consists of lower case English letters and brackets.  Reverse the strings in each pair of matching parentheses, starting from the innermost one. Your result should not contain any brackets. Example 1: Input: s = “(abcd)” Output: “dcba” Example 2: Input: s = “(u(love)i)” Output: “iloveu” Explanation: The substring “love” is reversed first, … Read more Reverse Substrings Between Each Pair of Parentheses in Python


Minimum Absolute Difference in Python

Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.  Return a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows a, b are from arr a < b b – a equals to the minimum absolute difference of any two elements in arr Example 1: Input: arr = [4,2,1,3] … Read more Minimum Absolute Difference in Python


Minimum Time Visiting All Points in Python

On a plane, there are n points with integer coordinates points[i] = [xi, yi]. Your task is to find the minimum time in seconds to visit all points. You can move according to the next rules: In one second always you can either move vertically, horizontally by one unit or diagonally (it means to move one unit vertically … Read more Minimum Time Visiting All Points in Python


Search Suggestions System in Python

Given an array of strings products and a string searchWord. We want to design a system that suggests at most three product names from products after each character of searchWord is typed. Suggested products should have common prefix with the searchWord. If there are more than three products with a common prefix return the three lexicographically minimums products. Return list of lists of the suggested products after each … Read more Search Suggestions System in Python