原创 Best Time to Buy and Sell Stock with Transaction Fee問題及解法

問題描述: Your are given an array of integers prices, for which the i-th element is the price of a given stock on day i;

原创 Longest Substring with At Least K Repeating Characters問題及解法

問題描述: Find the length of the longest substring T of a given string (consists of lowercase letters only) such that eve

原创 Sentence Similarity問題及解法

問題描述: Given two sentences words1, words2 (each represented as an array of strings), and a list of similar word pairs

原创 Longest Word in Dictionary問題及解法

問題描述: Given a list of strings words representing an English Dictionary, find the longest word in words that can be b

原创 Matchsticks to Square問題及解法

問題描述: Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match girl has, p

原创 Split Linked List in Parts問題及解法

問題描述: Given a (singly) linked list with head node root, write a function to split the linked list into k consecutive

原创 Bulls and Cows問題及解法

問題描述: You are playing the following Bulls and Cows game with your friend: You write down a number and ask your frien

原创 String Compression問題及解法

問題描述: Given an array of characters, compress it in-place. The length after compression must always be smaller than or

原创 Split Array into Consecutive Subsequences問題及解法

問題描述: You are given an integer array sorted in ascending order (may contain duplicates), you need to split them into

原创 My Calendar II問題及解法

問題描述: Implement a MyCalendarTwo class to store your events. A new event can be added if adding the event will not ca

原创 Find Duplicate Subtrees問題及解法

問題描述: Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to retur

原创 UTF-8 Validation問題及解法

問題描述: A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules: For 1-byte character, the

原创 Guess Number Higher or Lower II問題及解法

問題描述: We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which

原创 Longest Absolute File Path問題及解法

問題描述: Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2

原创 Find K Closest Elements問題及解法

問題描述: Given a sorted array, two integers k and x, find the k closest elements to x in the array. The result should