【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, ...
随机推荐
- C#需要在项目程序生成前后执行相关的事件
分享4: 需求:需要在项目程序生成前后执行相关的事件,比如:需要将某个文件拷贝到bin\Debug中,或者创建某文件夹等. 分析:我们可利用项目属性(选择项目右键,选择属性)中的“生成事件”预定义相关 ...
- SpringMVC 接受请求参数、作用域传值
目录 原生servlet接收参数 Spring MVC最基础的参数获取 接收基本数据类型参数 方法参数列表和请求参数不一致的处理方式 接收对象引用数据类型 接收复选框这种多个同名的参数 接收obj.f ...
- Idea在@Autowired注入时报错
Could not autowire. No beans of 'UserDao' type found 如图,是因为idea检测能力太强,一旦没有找到实现类就会报错,但是我试了,这里其实是注入进来了 ...
- React笔记:组件(3)
1. 组件定义 组件是React的核心概念,组件将应用的UI拆分成独立的.可复用的模块. 定义组件的两种方式: (1)类组件:使用ES6 class (2)函数组件:使用函数 使用class定义组件的 ...
- Java面试题之基础篇概览
Java面试题之基础篇概览 1.一个“.java”源文件中是否可以包含多个类(不是内部类)?有什么限制? 可以有多个类,但只能有一个public的类,且public的类名必须与文件名相一致. 2.Ja ...
- P1462 通往奥格瑞玛的道路
P1462 通往奥格瑞玛的道路 题目背景 在艾泽拉斯大陆上有一位名叫歪嘴哦的神奇术士,他是部落的中坚力量 有一天他醒来后发现自己居然到了联盟的主城暴风城 在被众多联盟的士兵攻击后,他决定逃回自己的家乡 ...
- Vscode生成verilog例化
前言 手动例化又慢又容易出错,孩子老犯错怎么办? 当然是脚本一劳永逸. 流程 (1)在vscode中安装如下插件. (2)在电脑中安装python3以上的环境. 下载地址:https://www.py ...
- Educational Codeforces Round 62 (Rated for Div. 2)C
题目链接 :C. Playlist #include<bits/stdc++.h> using namespace std; #define maxn 300005 #define LL ...
- 【洛谷P3649】回文串
题目大意:给定一个长度为 N 的字符串,定义一个变量为该字符串的回文子串长度乘以该字串出现的次数,求这个变量的最大值是多少. 题解:学会了回文自动机. 回文自动机是两棵树组成的森林结构,并通过 fai ...
- MySQL 水平拆分与垂直拆分详解
前言:说到优化mysql,总会有这么个回答:水平拆分,垂直拆分,那么我们就来说说什么是水平拆分,垂直拆分. 一.垂直拆分 说明:一个数据库由很多表的构成,每个表对应着不同的业务,垂直切分是指按照业务将 ...