网址: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. 【.Net】结合项目谈谈多线程

    提到多线程, 大家都知道, 在进程中启用多个线程进行工作, 会提升程序的效率等等. 本篇文章旨在解释多线程的基础概念之外, 还要结合实际的项目来谈多线程的具体使用. Thread 我们知道启动一个线程 ...

  2. CAS 单点登录4.24版本 登录调用其它系统并且返回客户端用其它的用户信息改造

    1.登录调用其它系统.修改deployerConfigContext.xml <?xml version="1.0" encoding="UTF-8"?& ...

  3. Lintcode9-Fizz Buzz-Easy

    Fizz Buzz Given number n. Print number from 1 to n. But: when number is divided by 3, print "fi ...

  4. jenkins 异常

    八月 03, 2017 7:23:54 下午 org.eclipse.jetty.util.log.JavaUtilLog warn 警告: FAILED ServerConnector@29e6eb ...

  5. 使用git上传项目到github的最基础命令

    一.前言 把github作为自己项目托管的地方,实在是一个明智的选择.就算你不为自己项目考虑,你也要为你团队项目开发而学呀!可能有些初学者(比如我)会觉得git命令好多啊,又是各种术语,觉得好难上手. ...

  6. java static方法不能被重写@Override

    重写方法的目的是为了多态,或者说:重写是实现多态的前提,即重写是发生在继承中且是针对非static方法的. 语法上子类允许出现和父类只有方法体不一样其他都一模一样的static方法,但是在父类引用指向 ...

  7. Qt5.QString传参数

    1.函数传参,如果是 QString&类型 的话,不能直接 传入 char* 类型的参数,若是声明成 const QString&类型 的话,就可以 解释:应该是 函数调用的时候 编译 ...

  8. [原][osgEarth][JSBSim]重新整理使用JSBSim飞机动力模拟的使用

    JSBSim是一个模拟飞机飞行空气动力学的,这些都不用深入理解,只要知道自己程序怎么和JSBSim交互就行了 我使用的是JSBSim-Win32-0.9.13 原理:改写jsbsim的FGInput ...

  9. JS _proto_ 和 prototype

    转载自:https://www.cnblogs.com/wuwenjie/p/5433776.html 大佬讲得很明白,自己也收藏一下! 初学javascript的时候也跟题主一样搞不清楚,自己好好总 ...

  10. 基于Arcface Android平台的人脸识别实现

    效果图 先上效果,让大家看看如何 现在有很多人脸识别的技术我们可以拿来使用:但是个人认为还是离线端的SDK比较实用:所以个人一直在搜集人脸识别的SDK:原来使用开源的OpenCV:最近有个好友推荐虹软 ...