Given aContinue reading “[Leetcode]139. Word Break”non-emptystringsand a dictionarywordDictcontaining a list ofnon-emptywords, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.Note:The same word in the dictionary may be reused multiple times in the segmentation. You may assume the dictionary does not contain duplicate words.

## [Leetcode]621. Task Scheduler

You are given a char array representing tasks CPU need to do. It contains capital letters A to Z where each letter represents a different task. Tasks could be done without the original order of the array. Each task is done in one unit of time. For each unit of time, the CPU could complete either one task or just be idle. However, there is a non-negative integerContinue reading “[Leetcode]621. Task Scheduler”`n`

that represents the cooldown period between twosame tasks(the same letter in the array), that is that there must be at least`n`

units of time between any two same tasks. You need to return theleastnumber of units of times that the CPU will take to finish all the given tasks.

## [Leetcode]42. Trapping Rain Water

GivenContinue reading “[Leetcode]42. Trapping Rain Water”nnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.Example:Input:height=[0,1,0,2,1,0,1,3,2,1,2,1]Output:6

## [Leetcode]260. Single Number III

Given an array of numbersContinue reading “[Leetcode]260. Single Number III”`nums`

, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.Example:Input:`[1,2,1,3,2,5]`

Output:`[3,5]`

## [Leetcode]1520. Maximum Number of Non-Overlapping Substrings

Given a stringContinue reading “[Leetcode]1520. Maximum Number of Non-Overlapping Substrings”`s`

of lowercase letters, you need to find the maximum number ofnon-emptysubstrings of`s`

that meet the following conditions: The substrings do not overlap, that is for any two substrings`s[i..j]`

and`s[k..l]`

, either`j < k`

or`i > l`

is true. A substring that contains a certain character`c`

must also contain all occurrences of`c`

. Findthe maximum number of substrings that meet the above conditions. If there are multiple solutions with the same number of substrings,return the one with minimum total length.It can be shown that there exists a unique solution of minimum total length. Notice that you can return the substrings inanyorder.

## Find maximum meetings in one room

There is one meeting room in a firm. There areContinue reading “Find maximum meetings in one room”Nmeetings in the form of(S[i], F[i])whereS[i]is the start time of meetingiandF[i]is finish time of meetingi. The task is to find the maximum number of meetings that can be accommodated in the meeting room. Print all meeting numbersExamples:Input :s[] = {1, 3, 0, 5, 8, 5}, f[] = {2, 4, 6, 7, 9, 9}Output :1 2 4 5 First meeting [1, 2] Second meeting [3, 4] Fourth meeting [5, 7] Fivth meeting [8, 9]

## [Leetcode]253. Meeting Rooms II

Given an array of meeting time intervals consisting of start and end timesContinue reading “[Leetcode]253. Meeting Rooms II”`[[s1,e1],[s2,e2],...]`

(s_{i}< e_{i}), find the minimum number of conference rooms required.Example 1:Input:`[[0, 30],[5, 10],[15, 20]]`

Output:2

## [Leetcode]252. Meeting Rooms

Given an array of meeting time intervals consisting of start and end timesContinue reading “[Leetcode]252. Meeting Rooms”`[[s1,e1],[s2,e2],...]`

(s_{i}< e_{i}), determine if a person could attend all meetings.Example 1:Input:`[[0,30],[5,10],[15,20]]`

Output:false