Skip to content

Commit 19adb54

Browse files
add skeleton for 1165
1 parent 292d113 commit 19adb54

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Your ideas/fixes/algorithms are more than welcome!
3434
|1207|[Unique Number of Occurrences](https://leetcode.com/problems/unique-number-of-occurrences/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1207.java) | O(n) | O(1) | |Easy||
3535
|1200|[Minimum Absolute Difference](https://leetcode.com/problems/minimum-absolute-difference/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1200.java) | || [:tv:](https://www.youtube.com/watch?v=mH1aEjOEjcQ)|Easy||
3636
|1185|[Day of the Week](https://leetcode.com/problems/day-of-the-week/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1185.java) | | | |Easy||
37+
|1165|[Single-Row Keyboard](https://leetcode.com/problems/single-row-keyboard/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1165.java) | | | |Easy||
3738
|1160|[Find Words That Can Be Formed by Characters](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1160.java) | O(n) | O(m) | |Easy||
3839
|1154|[Day of the Year](https://leetcode.com/problems/day-of-the-year/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1154.java) | O(1) | O(1) | |Easy||
3940
|1137|[N-th Tribonacci Number](https://leetcode.com/problems/n-th-tribonacci-number/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1137.java) | O(n) | O(n) | |Easy||
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.fishercoder.solutions;
2+
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+
* */
29+
public class _1165 {
30+
public static class Solution1 {
31+
public int calculateTime(String keyboard, String word) {
32+
return -1;
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)