摘要:
题目描述 实现获取下一个排列的函数,算法需要将给定数字序列重新排列成字典序中下一个更大的排列。如果不存在下一个更大的排列,则将数字重新排列成最小的排列(即升序排列)。 必须原地修改,只允许使用额外常数空间。 以下是一些例子,输入位于左侧列,其相应输出位于右侧列。 1,2,3 → 1,3,2 3,2, 阅读全文
2021年5月3日
摘要:
题目描述 给定一个可包含重复数字的序列,返回所有不重复的全排列。 示例: 输入: [1,1,2] 输出: [ [1,1,2], [1,2,1], [2,1,1] ] 思路 相当于找出所有不同的num.size()元组来,我们只需要保证设计程序时,对于这个元组每个位置的可能情况枚举时,每次做到不重复, 阅读全文
摘要:
题目描述 给定一个没有重复数字的序列,返回其所有可能的全排列。 示例: 输入: [1,2,3] 输出: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] 代码 class Solution { public: vector<vector 阅读全文
摘要:
题目描述 Given a collection of integers that might contain duplicates, S, return all possible subsets. Note: Elements in a subset must be in non-descendin 阅读全文
摘要:
题目描述 Given a set of distinct integers, S, return all possible subsets. Note: Elements in a subset must be in non-descending order(非下降顺序,升序).The soluti 阅读全文
2021年5月2日
摘要:
题目描述 Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each wor 阅读全文
摘要:
题目描述 Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. 阅读全文
摘要:
题目描述 给定一个仅包含大小写字母和空格 ' ' 的字符串,返回其最后一个单词的长度。如果不存在最后一个单词,请返回 0 。 说明:一个单词是指由字母组成,但不包含任何空格的字符串。 示例: 输入: "Hello World" 输出: 5 代码实现 class Solution { public: 阅读全文
摘要:
题目描述 Given two words (beginWord and endWord), and a dictionarys word list, find all shortest transformation sequence(s) from beginWord o endWord, such 阅读全文