[LeetCode&Python] Problem 784. Letter Case Permutation
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.
Examples:
Input: S = "a1b2"
Output: ["a1b2", "a1B2", "A1b2", "A1B2"] Input: S = "3z4"
Output: ["3z4", "3Z4"] Input: S = "12345"
Output: ["12345"]
Note:
Swill be a string with length between1and12.Swill consist only of letters or digits.
import itertools
class Solution(object):
def letterCasePermutation(self, S):
"""
:type S: str
:rtype: List[str]
"""
L=[[i.upper(),i.lower()] if i.isalpha() else i for i in S]
return [''.join(i) for i in itertools.product(*L)]
[LeetCode&Python] Problem 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 ...
- 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 ...
- 784. Letter Case Permutation 字符串中字母的大小写组合
[抄题]: Given a string S, we can transform every letter individually to be lowercase or uppercase to c ...
- 784. Letter Case Permutation C++字母大小写全排列
网址:https://leetcode.com/problems/letter-case-permutation/ basic backtracking class Solution { public ...
- 【easy】784. Letter Case Permutation
Examples: Input: S = "a1b2" Output: ["a1b2", "a1B2", "A1b2", ...
- 784. Letter Case Permutation
这个题的思想很重要,两种方法 第一种,回溯法 class Solution { public: int sz; vector<string> letterCasePermutation(s ...
- [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 ...
随机推荐
- laravel框架5.2版本组件包开发
一.包的作用 1 把功能相似或相关的类或接口组织在同一个包中,方便类的查找和使用. 2 如同文件夹一样,包也采用了树形目录的存储方式.同一个包中的类名字是不同的,不同的包中的类的名字是可以相同的, ...
- Linux command automake
Linux command automake [Purpose] Learning linux command automake for generate Makefile.in for ...
- netty]--最通用TCP黏包解决方案
netty]--最通用TCP黏包解决方案:LengthFieldBasedFrameDecoder和LengthFieldPrepender 2017年02月19日 15:02:11 惜暮 阅读数:1 ...
- Blazor
https://docs.microsoft.com/zh-cn/windows/uwp/get-started/construct-form-learning-track https://docs. ...
- unity中UI的屏幕自适应代码
public void ScreenUISelfAdptation(Transform scaleUI) { float widthrate = UnityEngine.Screen.width / ...
- linux:scp从入门到刚入门
[温馨提示] 此文和ssh配合食用更佳. 首先请小伙伴们连上你要传文件的那台机,用ssh可以免密登录. [传送文件] 我们一般发文件的话可以scp来发一发,比如说我现在要向多个扔很多tomcat包,我 ...
- sqlserver查询父子级关系
自上向下的查询方法,查询出自身以及所有的子孙数据: --自上往下搜索 ;with maco as ( union all select t.* from ty_Dictionary t,maco m ...
- 【转载二】Grafana系列教程–Grafana的下载及安装
本篇教程,waitig 来为大家介绍一下Grafana的安装及运行的方式. 更多Grafana技术请加入<InfluxDB&Grafana技术交流群:580487672(点击加入)> ...
- .tar.gz 和.tgz 解压
wget {url} 下载 eg: wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.24/bin/apac ...
- Problem A: 编写函数:三个数的最大最小值
Description 给出三个数a,b,c,最大值是?最小值是? ------------------------------------------------------------------ ...