1249. Minimum Remove to Make Valid Parentheses

Problem statement Given a string s of ( , ) and lowercase English characters. Your task is to remove the minimum number of parentheses ( ( or ), in any positions ) so that the resulting parentheses string is valid and return any valid string. Formally, a parentheses string is valid if and only if: It is the empty string, contains only lowercase characters, or It can be written as AB (A concatenated with B), where A and B are valid strings, or It can be written as (A), where A is a valid string....

April 24, 2021 · 2 min · Me

1482. Minimum Number of Days to Make m Bouquets

Problem Statement Given an integer array bloomDay, an integer m and an integer k. We need to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden. The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet. Return the minimum number of days you need to wait to be able to make m bouquets from the garden....

August 15, 2020 · 2 min · Me

567. Permutation in String

Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string’s permutations is the substring of the second string. Example 1: Input: s1 = “ab” s2 = “eidbaooo” Output: True Explanation: s2 contains one permutation of s1 (“ba”). Example 2: Input:s1= “ab” s2 = “eidboaoo” Output: False class Solution { public boolean checkInclusion(String s1, String s2) { Map<Character, Integer> map = new HashMap<>(); for (char ch : s1....

March 21, 2020 · 1 min · Me

524. Longest Word in Dictionary through Deleting

Problem Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string. Example 1: Input: s = “abpcplea”, d = [“ale”,“apple”,“monkey”,“plea”] Output: “apple” Example 2: Input: s = “abpcplea”, d = [“a”,“b”,“c”]...

March 7, 2020 · 2 min · Me

Leetcode Course Schedule

Java Solutions of Course Schedule

October 30, 2019 · 1 min · Me