Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5021334

Browse files
refactor 1165
1 parentc0b52ab commit5021334

File tree

1 file changed

+0
-26
lines changed

1 file changed

+0
-26
lines changed

‎src/main/java/com/fishercoder/solutions/_1165.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,5 @@
11
packagecom.fishercoder.solutions;
22

3-
/**
4-
* 1165. Single-Row Keyboard
5-
*
6-
* There is a special keyboard with all keys in a single row.
7-
* Given a string keyboard of length 26 indicating the layout of the keyboard (indexed from 0 to 25),
8-
* initially your finger is at index 0.
9-
* To type a character, you have to move your finger to the index of the desired character. The time taken to move your finger from index i to index j is |i - j|.
10-
*
11-
* You want to type a string word. Write a function to calculate how much time it takes to type it with one finger.
12-
*
13-
* Example 1:
14-
* Input: keyboard = "abcdefghijklmnopqrstuvwxyz", word = "cba"
15-
* Output: 4
16-
* Explanation: The index moves from 0 to 2 to write 'c' then to 1 to write 'b' then to 0 again to write 'a'.
17-
* Total time = 2 + 1 + 1 = 4.
18-
*
19-
* Example 2:
20-
* Input: keyboard = "pqrstuvwxyzabcdefghijklmno", word = "leetcode"
21-
* Output: 73
22-
*
23-
* Constraints:
24-
* keyboard.length == 26
25-
* keyboard contains each English lowercase letter exactly once in some order.
26-
* 1 <= word.length <= 10^4
27-
* word[i] is an English lowercase letter.
28-
* */
293
publicclass_1165 {
304
publicstaticclassSolution1 {
315
publicintcalculateTime(Stringkeyboard,Stringword) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp