【easy】784. Letter Case Permutation
Examples:
Input: S = "a1b2"
Output: ["a1b2", "a1B2", "A1b2", "A1B2"] Input: S = "3z4"
Output: ["3z4", "3Z4"] Input: S = "12345"
Output: ["12345"]
class Solution {
public:
vector<string> letterCasePermutation(string S) {
vector<string> res;
int idx = ;
helper(S, idx, res);
return res;
}
void helper(string& s, int idx, vector<string>& res) {
if (idx == s.size()) {
res.push_back(s);
return;
}
helper(s, idx + , res);
if (isalpha(s[idx])) {
s[idx] = islower(s[idx]) ? toupper(s[idx]) : tolower(s[idx]);
helper(s, idx + , res);
}
}
};
【easy】784. Letter Case Permutation的更多相关文章
- 【Leetcode_easy】784. Letter Case Permutation
problem 784. Letter Case Permutation 参考 1. Leetcode_easy_784. Letter Case Permutation; 2. Grandyang; ...
- 【LeetCode】784. Letter Case Permutation 解题报告 (Python&C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 回溯法 循环 日期 题目地址:https://leet ...
- 784. Letter Case Permutation 字符串中字母的大小写组合
[抄题]: Given a string S, we can transform every letter individually to be lowercase or uppercase to c ...
- leetcode 784. Letter Case Permutation——所有BFS和DFS的题目本质上都可以抽象为tree,这样方便你写代码
Given a string S, we can transform every letter individually to be lowercase or uppercase to create ...
- LeetCode 784 Letter Case Permutation 解题报告
题目要求 Given a string S, we can transform every letter individually to be lowercase or uppercase to cr ...
- [LeetCode&Python] Problem 784. Letter Case Permutation
Given a string S, we can transform every letter individually to be lowercase or uppercase to create ...
- 784. Letter Case Permutation C++字母大小写全排列
网址:https://leetcode.com/problems/letter-case-permutation/ basic backtracking class Solution { public ...
- 784. Letter Case Permutation
这个题的思想很重要,两种方法 第一种,回溯法 class Solution { public: int sz; vector<string> letterCasePermutation(s ...
- 【LeetCode】17. Letter Combinations of a Phone Number 电话号码的字母组合
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 个人公众号:负雪明烛 本文关键词:电话号码, 字母组合,回溯法,题解,leetcode, ...
随机推荐
- java基础-jdk工具包
1. 标准工具 这些工具都是JDK提供的,通常都是长期支持的工具,JDK承诺这些工具比较好用.不同系统.不同版本之间可能会有差异,但是不会突然就有一个工具消失. 1.1 基础包 (extcheck, ...
- [转帖]deb包转化为rpm包
deb包转化为rpm包 https://www.cnblogs.com/noxy/p/6371399.html 改天尝试一下之前经常遇到能下载deb包 下载不到rpm包的情况. deb文件格式本是ub ...
- day02-运算符 and 和 or 的用法
# 运算符的优先级 # () > not > and > or # and 必须两边表达式都为真,才为真 # or 如果表达式有一边为真,则为真 # not 表示非.比如 not 2 ...
- 【ML】从特征分解,奇异值分解到主成分分析
1.理解特征值,特征向量 一个对角阵\(A\),用它做变换时,自然坐标系的坐标轴不会发生旋转变化,而只会发生伸缩,且伸缩的比例就是\(A\)中对角线对应的数值大小. 对于普通矩阵\(A\)来说,是不是 ...
- 关于bytes和bytearray
背景 平时工作因为有批量线上数据进行更新,通过Python程序连接数据库,利用连接池和gevent的并发性能,处理大量数据. 因为数据方提供的数据表结构中带有varbinary类型字段,并非全部,所以 ...
- 机器学习KNN算法
KNN(最邻近规则分类K-Nearest-Neighibor)KNN算法 1. 综述 1.1 Cover和Hart在1968年提出了最初的邻近算法 1.2 分类(classific ...
- SpringBoot文件上传(MVC情况和webFlux情况)
MVC情况 引入依赖 <?xml version="1.0" encoding="UTF-8"?> <project xmlns=" ...
- X-pack 6.4.0 破解
X-package 6.4.0 破解 获取x-pack-core-6.4.0.jar 下载 elasticsearch下载页面:https://www.elastic.co/downloads/ela ...
- MDK调试无法进入main()函数
今天在用MDK调试stm32时出现了无法进入main函数,进入startup文件的情况. 在网上查找资料时发现,MDK调试设置断点最多只能设置5个.在减少断点后,调试果然能够正常进入main()函数了 ...
- Centos7.2正常启动关闭CDH5.16.1
1.正常的启动.关闭流程 关闭流程 cluster1 stop Cloudera Management Service stop 4台agent:systemctl stop cloudera ...