Skip to content

Commit 84388b1

Browse files
committed
Add solution #744
1 parent 5eef00f commit 84388b1

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@
273273
733|[Flood Fill](./0733-flood-fill.js)|Easy|
274274
735|[Asteroid Collision](./0735-asteroid-collision.js)|Medium|
275275
739|[Daily Temperatures](./0739-daily-temperatures.js)|Medium|
276+
744|[Find Smallest Letter Greater Than Target](./0744-find-smallest-letter-greater-than-target.js)|Easy|
276277
745|[Prefix and Suffix Search](./0745-prefix-and-suffix-search.js)|Hard|
277278
746|[Min Cost Climbing Stairs](./0746-min-cost-climbing-stairs.js)|Easy|
278279
747|[Largest Number At Least Twice of Others](./0747-largest-number-at-least-twice-of-others.js)|Easy|
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* 744. Find Smallest Letter Greater Than Target
3+
* https://leetcode.com/problems/find-smallest-letter-greater-than-target/
4+
* Difficulty: Easy
5+
*
6+
* You are given an array of characters letters that is sorted in non-decreasing order,
7+
* and a character target. There are at least two different characters in letters.
8+
*
9+
* Return the smallest character in letters that is lexicographically greater than target.
10+
* If such a character does not exist, return the first character in letters.
11+
*/
12+
13+
/**
14+
* @param {character[]} letters
15+
* @param {character} target
16+
* @return {character}
17+
*/
18+
var nextGreatestLetter = function(letters, target) {
19+
return letters.find(l => l > target) || letters[0];
20+
};

0 commit comments

Comments
 (0)