# 784.Letter Case Permutation

**784.Letter Case Permutation**

难度:Easy

> 给定一个字符串S，通过将字符串S中的每个字母转变大小写，我们可以获得一个新的字符串。返回所有可能得到的字符串集合。

```
示例:
输入: S = "a1b2"
输出: ["a1b2", "a1B2", "A1b2", "A1B2"]

输入: S = "3z4"
输出: ["3z4", "3Z4"]

输入: S = "12345"
输出: ["12345"]
注意：

S 的长度不超过12。
S 仅由数字和字母组成。
```

一个一个加进去。

```
class Solution {
public:
    vector<string> letterCasePermutation(string S) {
        vector<string>res;
        res.push_back("");
        for(auto c : S)
        {
            int N=res.size();   
            if(c>='a' && c<='z')
            {
                for(int i=0;i<N;i++)
                {
                    
                    c-=32;
                    res.push_back(res[i]+c);
                     c+=32;
                    res[i]+=c;
                }
            }
            else if (c>='A' && c<='Z')
                 for(int i=0;i<N;i++)
                {
                  
                     c+=32;
                    res.push_back(res[i]+c);
                       c-=32;
                     res[i]+=c;
                }
            else
             for(int i=0;i<N;i++)
                {
                    res[i]+=c;
            }
        }
        return res;
        
    }
};
```

> 执行用时 : 28 ms, 在Letter Case Permutation的C++提交中击败了54.25% 的用户\
> 内存消耗 : 12 MB, 在Letter Case Permutation的C++提交中击败了91.53% 的用户


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dfine.gitbook.io/leetcode/784.letter_case_permutation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
