Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string.  Return a list of all possible strings we could create.

  1. Examples:
  2. Input: S = "a1b2"
  3. Output: ["a1b2", "a1B2", "A1b2", "A1B2"]
  4.  
  5. Input: S = "3z4"
  6. Output: ["3z4", "3Z4"]
  7.  
  8. Input: S = "12345"
  9. Output: ["12345"]

Note:

  • S will be a string with length between 1 and 12.
  • S will consist only of letters or digits.
  1. import itertools
  2. class Solution(object):
  3. def letterCasePermutation(self, S):
  4. """
  5. :type S: str
  6. :rtype: List[str]
  7. """
  8. L=[[i.upper(),i.lower()] if i.isalpha() else i for i in S]
  9. return [''.join(i) for i in itertools.product(*L)]

  

[LeetCode&Python] Problem 784. Letter Case Permutation的更多相关文章

  1. 【Leetcode_easy】784. Letter Case Permutation

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

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

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

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

  4. LeetCode 784 Letter Case Permutation 解题报告

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

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

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

  6. 784. Letter Case Permutation C++字母大小写全排列

    网址:https://leetcode.com/problems/letter-case-permutation/ basic backtracking class Solution { public ...

  7. 【easy】784. Letter Case Permutation

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

  8. 784. Letter Case Permutation

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

  9. [LeetCode&Python] Problem 520. Detect Capital

    Given a word, you need to judge whether the usage of capitals in it is right or not. We define the u ...

随机推荐

  1. Oracle常用表和常见操作命令

    一.说明 Oracle数据库数据库名.表名.字段名等不区分大小写,字段值区分大小写. Oracle单词之间一般用下划线连接:表名最后一般加s字段名最后一般没s. 二.常见数据表 dba_*DBA拥有的 ...

  2. png文件格式详解,获取文件的修改时间,创作时间

    http://dev.gameres.com/Program/Visual/Other/PNGFormat.htmhttp://www.360doc.com/content/11/0428/12/10 ...

  3. 把旧系统迁移到.Net Core 2.0 日记(2) - 依赖注入/日志NLog

    Net Core 大量使用依赖注入(Dependency Inject), 打个比方,我们常用的日志组件有Log4Net,NLog等等. 如果我们要随时替换日志组件,那么代码中就不能直接引用某个组件的 ...

  4. Oracle 如何将“26-9月 -17 06.46.00.000000000 下午”字符串转换成标准日期格式

    今天,在读取日期格式数据时,出现这样的格式“26-9月 -17 06.46.00.000000000 下午”,在网上找了一下, 这个也是oracle的一种日期保存格式,数据都是日期类型,只是显示的结果 ...

  5. Win10系列:VC++ Direct3D图形绘制1

    通过前面的介绍,相信读者已经了解了如何新建一个用于开发Direct3D应用程序的项目模版,以及这个项目模版中用于绘制立体图形的主要函数.在本小节中,将通过一个具体的示例来介绍如何使用Visual St ...

  6. ios 设置本地化显示的app名称

    内容的本地化这里不做介绍! 名称的本地化: 1.新建一个 Strings File文件,命名为InfoPlist,注意这里一定要命名为InfoPlist! 2.设置本地化信息:选择需要的语言! 3.填 ...

  7. Python实战之logging模块使用详解

    用Python写代码的时候,在想看的地方写个print xx 就能在控制台上显示打印信息,这样子就能知道它是什么了,但是当我需要看大量的地方或者在一个文件中查看的时候,这时候print就不大方便了,所 ...

  8. 扩展HtmlHelper类实现Mvc4分页

    1.扩展HtmlHelper类方法Pager public static HtmlString Pager(this HtmlHelper htmlHelper, int currentPage, i ...

  9. MySQL:基础知识

    基础知识 一.软件的生命周期 软件定义 软件开发 软件使用与维护 二.数据(Data) 1.定义 描述客观事物特征或性质的某种符号,经过数字化处理存储在计算机 2.数据独立性 物理独立性:指用户的应用 ...

  10. webrtc 音频一点相关知识

    采样频率:  44.1kHz ,它的意思是每秒取样44100次   .8kHz    8000次,  16kHz   160000次 比特率:  比特率是大家常听说的一个名词,数码录音一般使用16比特 ...