SnowScriptWinterOfCode / LeetCode_Q

Solve with us the most mind boggling DSA questions to ace your skills
2 stars 50 forks source link

Day30 q2: Find Smallest Letter Greater Than Target #619

Open sumiranverma opened 7 months ago

sumiranverma commented 7 months ago

You are given an array of characters letters that is sorted in non-decreasing order, and a character target. There are at least two different characters in letters.

Return the smallest character in letters that is lexicographically greater than target. If such a character does not exist, return the first character in letters.

Example 1:

Input: letters = ["c","f","j"], target = "a" Output: "c" Explanation: The smallest character that is lexicographically greater than 'a' in letters is 'c'.

Example 2:

Input: letters = ["c","f","j"], target = "c" Output: "f" Explanation: The smallest character that is lexicographically greater than 'c' in letters is 'f'.

Example 3:

Input: letters = ["x","x","y","y"], target = "z" Output: "x" Explanation: There are no characters in letters that is lexicographically greater than 'z' so we return letters[0].

Constraints:

Problem Link

https://leetcode.com/problems/find-smallest-letter-greater-than-target/

Tech-neophyte commented 7 months ago

Please assign this question to me :)

Anomasingh commented 7 months ago

Please assign this question to me @bh-g

avanimathur commented 7 months ago

Please assign it to me @bh-g