网址:https://leetcode.com/problems/letter-case-permutation/

basic backtracking

class Solution {
public:
void backTrack(string s, string res, int i, vector<string> &ans)
{
if (i == s.size())
{
ans.push_back(res);
return;
}
if (!isalpha(s[i]))
backTrack(s, res + s[i], i + , ans);
else
{
backTrack(s, res + (char)tolower(s[i]), i + , ans);
backTrack(s, res + (char)toupper(s[i]), i + , ans);
}
} vector<string> letterCasePermutation(string S)
{
vector<string> ans;
string res;
backTrack(S, res, , ans);
return ans;
}
};

784. Letter Case Permutation C++字母大小写全排列的更多相关文章

  1. 【Leetcode_easy】784. Letter Case Permutation

    problem 784. Letter Case Permutation 参考 1. Leetcode_easy_784. Letter Case Permutation; 2. Grandyang; ...

  2. 784. Letter Case Permutation

    这个题的思想很重要,两种方法 第一种,回溯法 class Solution { public: int sz; vector<string> letterCasePermutation(s ...

  3. 784. Letter Case Permutation 字符串中字母的大小写组合

    [抄题]: Given a string S, we can transform every letter individually to be lowercase or uppercase to c ...

  4. 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 ...

  5. 【LeetCode】784. Letter Case Permutation 解题报告 (Python&C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 回溯法 循环 日期 题目地址:https://leet ...

  6. LeetCode 784 Letter Case Permutation 解题报告

    题目要求 Given a string S, we can transform every letter individually to be lowercase or uppercase to cr ...

  7. [LeetCode&Python] Problem 784. Letter Case Permutation

    Given a string S, we can transform every letter individually to be lowercase or uppercase to create ...

  8. 【easy】784. Letter Case Permutation

    Examples: Input: S = "a1b2" Output: ["a1b2", "a1B2", "A1b2", ...

  9. Java实现 LeetCode 784 字母大小写全排列(DFS)

    784. 字母大小写全排列 给定一个字符串S,通过将字符串S中的每个字母转变大小写,我们可以获得一个新的字符串.返回所有可能得到的字符串集合. 示例: 输入: S = "a1b2" ...

随机推荐

  1. 【JS】js操作json object

    //将表单序列化成字符串 $.fn.serializeObject = function () { var obj = {}; var count = 0; $.each(this.serialize ...

  2. 【转载】C++宏定义详解

    摘自:http://blog.chinaunix.net/uid-21372424-id-119797.html   C++宏定义详解 2011-02-14 23:33:24   分类: C/C++ ...

  3. NOIP2018退役祭

    退役感受 在写下这个标题的时候,我的心情是复杂的,无非就是感觉像对一位将要赶往战场的士兵说:"你的战争已经输掉了." 退役了,没有什么好说的.无论再怎么抱怨这题出的真烂也无法改变了 ...

  4. npm介绍和使用

    # npm 介绍 > 概念 : node 包管理工具 > 作用 : 通过 npm 来快速下载/安装项目中依赖的包 > 查看 版本号 : npm -v     # npm 基本使用演示 ...

  5. 性能跃升50%!解密自主研发的金融级分布式关系数据库OceanBase 2.0

    小蚂蚁说: 相信大家对蚂蚁金服自主研发的金融级分布式关系数据库OceanBase的故事不再陌生了.在刚刚过去的2018年天猫双11中,成交额2135亿再次创造了新纪录,而支撑今年双11的支付宝核心链路 ...

  6. oracle的批量操作sql语句

    1.批量删除/批量更新 mapper: <update id="updatePrjStateByFPrjId" parameterType="string" ...

  7. PHP运算符优先级

    if (!$a = $b) { // todo } if (!($a = $b)) { // todo } if ($a = !$b) { // todo } if ($a = (!$b)) { // ...

  8. 一个请求需要调用两个不同的数据库 添加DbContext

    当请求进入application中的方法时 会开启一个工作单元    这里面调用不同的DbContext 会默认使用第一次调用的DbContext 需要手动开启工作单元来隔离两个不同的DbContex ...

  9. 网页常见单位: px em pt % rem vw、vh、vmin、vmax , rem 使用

    1.网页常见单位:  px  em  pt    vw\vh   rem 1.1 px单位名称为像素,相对长度单位,像素(px)是相对于显示器屏幕分辨率而言  (最终解析单位) em单位名称为相对长度 ...

  10. java再次学习

    1.maven配置.