中文


[leetcode] Unique Word Abbreviation

Unique Word Abbreviation An abbreviation of a word follows the form <first letter><number><last letter>. Below are some examples of word abbreviations: a) it –> it (no abbreviation) 1 b) d|o|g –> d1g 1 1 1 1—5—-0—-5–8 c) i|nternationalizatio|n –> i18n 1 1—5—-0 d) l|ocalizatio|n –> l10n Assume you have a […]


[leetcode] Palindrome Permutation II

Palindrome Permutation II Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form. For example: Given s = “aabb”, return [“abba”, “baab”]. Given s = “abc”, return []. First, count the frequency of the each character […]


[leetcode] H-Index

H-Index Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher’s h-index. According to the definition of h-index on Wikipedia: “A scientist has index h if h of his/her N papers have at leasth citations each, and the other […]


[leetcode] Peeking Iterator

Peeking Iterator Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation — it essentially peek() at the element that will be returned by the next call to next(). Here is an example. Assume that the iterator is initialized to […]