Next Permutation

31. Next Permutation Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascendi...

Reverse Nodes in k-Group

25. Reverse Nodes in k-Group Given a linked list, reverse the nodes of a linked list _k_ at a time and return its modified list. If the number of nodes is not a multiple of _k_ then left-out nodes in the end should remain as it is. You may not alt...

Letter Combinations of a Phone Number

Letter Combinations of a Phone Number

17. Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string "23" Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]. Note: Al...

Longest Palindromic Substring QuestionEditorial Solution

Longest Palindromic Substring QuestionEditorial Solution

Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 题目:给出一个字符串S,找到一个最长的连续回文串。 题解: 这里用到了一个叫Manacher’s Algorithm的算法。 算法首先将输入字符串S, 转换成一个特殊字...

A+B问题

问题描述:给出两个整数a和b,求他们的和, 但不能使用+等数学运算符。 说明 a和b都是 32位 整数么? 是的 我可以使用位运算符么? 当然可以 样例 如果 a=1 并且 b=2,返回3   思路:很明显,题目...

排列与组合的实现

全排列 例如对于字符串“abc”,我们应该输出“abc”,“acb”,“bac”,“bca”,“cab”,“cba” 首先考虑“bac”和“cba”这两个字符串是怎么出现的,显然...