1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (English)/键盘行(English) [keyboard-row].html

50 lines
2.1 KiB
HTML
Raw Normal View History

2022-03-27 20:52:13 +08:00
<p>Given an array of strings <code>words</code>, return <em>the words that can be typed using letters of the alphabet on only one row of American keyboard like the image below</em>.</p>
2025-01-09 20:29:41 +08:00
<p><strong>Note</strong> that the strings are <strong>case-insensitive</strong>, both lowercased and uppercased of the same letter are treated as if they are at the same row.</p>
2022-03-27 20:52:13 +08:00
<p>In the <strong>American keyboard</strong>:</p>
<ul>
<li>the first row consists of the characters <code>&quot;qwertyuiop&quot;</code>,</li>
<li>the second row consists of the characters <code>&quot;asdfghjkl&quot;</code>, and</li>
<li>the third row consists of the characters <code>&quot;zxcvbnm&quot;</code>.</li>
</ul>
<img alt="" src="https://assets.leetcode.com/uploads/2018/10/12/keyboard.png" style="width: 800px; max-width: 600px; height: 267px;" />
<p>&nbsp;</p>
2023-12-09 18:42:21 +08:00
<p><strong class="example">Example 1:</strong></p>
2022-03-27 20:52:13 +08:00
2025-01-09 20:29:41 +08:00
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">words = [&quot;Hello&quot;,&quot;Alaska&quot;,&quot;Dad&quot;,&quot;Peace&quot;]</span></p>
<p><strong>Output:</strong> <span class="example-io">[&quot;Alaska&quot;,&quot;Dad&quot;]</span></p>
<p><strong>Explanation:</strong></p>
<p>Both <code>&quot;a&quot;</code> and <code>&quot;A&quot;</code> are in the 2nd row of the American keyboard due to case insensitivity.</p>
</div>
2022-03-27 20:52:13 +08:00
2023-12-09 18:42:21 +08:00
<p><strong class="example">Example 2:</strong></p>
2022-03-27 20:52:13 +08:00
2025-01-09 20:29:41 +08:00
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">words = [&quot;omk&quot;]</span></p>
<p><strong>Output:</strong> <span class="example-io">[]</span></p>
</div>
2022-03-27 20:52:13 +08:00
2023-12-09 18:42:21 +08:00
<p><strong class="example">Example 3:</strong></p>
2022-03-27 20:52:13 +08:00
2025-01-09 20:29:41 +08:00
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">words = [&quot;adsdf&quot;,&quot;sfd&quot;]</span></p>
<p><strong>Output:</strong> <span class="example-io">[&quot;adsdf&quot;,&quot;sfd&quot;]</span></p>
</div>
2022-03-27 20:52:13 +08:00
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= words.length &lt;= 20</code></li>
<li><code>1 &lt;= words[i].length &lt;= 100</code></li>
<li><code>words[i]</code> consists of English letters (both lowercase and uppercase).&nbsp;</li>
</ul>