题目描述: 给定两个句子 A 和 B . (句子是一串由空格分隔的单词.每个单词仅由小写字母组成.) 如果一个单词在其中一个句子中只出现一次,在另一个句子中却没有出现,那么这个单词就是不常见的. 返回所有不常用单词的列表. 您可以按任何顺序返回列表. 示例 1: 输入:A = "this apple is sweet", B = "this apple is sour" 输出:["sweet","sour"] 示例 2: 输入
Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: "tree" Output: "eert" Explanation: 'e' appears twice while 'r' and 't' both appear once. So 'e' must appear before both 'r' and 't'. Th
从n根筷子里面, 选择k+8个集合的筷子,每个集合三根筷子, A<=B<=C, 费用是(A-B)^2, 问最小的费用是多少. 将n根筷子排序之后,可以知道A和B的下标一定是连续的. 比如有 A B C D , 那么不可能是A C 一个集合, B D一个集合, 因为这样费用反而更大. 设dp[i][j] 为第i个集合的筷子,以j结尾, 就是说 A和B分别是第j和第j-1个筷子 dp[i][j] = min(dp[i-1][k]) + (a[j]-a[j-1])^2 那么如何处理第三根筷子呢?
S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sorted in some custom order previously. We want to permute the characters of T so that they match the order that S was sorted. More specifically, if x occ
Moscow is hosting a major international conference, which is attended by n scientists from different countries. Each of the scientists knows exactly one language. For convenience, we enumerate all languages of the world with integers from 1 to 109. I