You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: solution/1800-1899/1858.Longest Word With All Prefixes/README_EN.md
+5-24
Original file line number
Diff line number
Diff line change
@@ -20,63 +20,44 @@ tags:
20
20
<p>Given an array of strings <code>words</code>, find the <strong>longest</strong> string in <code>words</code> such that <strong>every prefix</strong> of it is also in <code>words</code>.</p>
21
21
22
22
<ul>
23
-
24
-
<li>For example, let <code>words = ["a", "app", "ap"]</code>. The string <code>"app"</code> has prefixes <code>"ap"</code> and <code>"a"</code>, all of which are in <code>words</code>.</li>
25
-
23
+
<li>For example, let <code>words = ["a", "app", "ap"]</code>. The string <code>"app"</code> has prefixes <code>"ap"</code> and <code>"a"</code>, all of which are in <code>words</code>.</li>
26
24
</ul>
27
25
28
26
<p>Return <em>the string described above. If there is more than one string with the same length, return the <strong>lexicographically smallest</strong> one, and if no string exists, return </em><code>""</code>.</p>
29
27
30
28
<p> </p>
31
-
32
29
<p><strongclass="example">Example 1:</strong></p>
33
30
34
31
<pre>
35
-
36
32
<strong>Input:</strong> words = ["k","ki","kir","kira", "kiran"]
37
-
38
33
<strong>Output:</strong> "kiran"
39
-
40
34
<strong>Explanation:</strong> "kiran" has prefixes "kira", "kir", "ki", and "k", and all of them appear in words.
41
-
42
35
</pre>
43
36
44
37
<p><strongclass="example">Example 2:</strong></p>
45
38
46
39
<pre>
47
-
48
40
<strong>Input:</strong> words = ["a", "banana", "app", "appl", "ap", "apply", "apple"]
49
-
50
41
<strong>Output:</strong> "apple"
51
-
52
42
<strong>Explanation:</strong> Both "apple" and "apply" have all their prefixes in words.
53
-
54
43
However, "apple" is lexicographically smaller, so we return that.
55
-
56
44
</pre>
57
45
58
46
<p><strongclass="example">Example 3:</strong></p>
59
47
60
48
<pre>
61
-
62
49
<strong>Input:</strong> words = ["abc", "bc", "ab", "qwe"]
Copy file name to clipboardexpand all lines: solution/2000-2099/2073.Time Needed to Buy Tickets/README_EN.md
+32-17
Original file line number
Diff line number
Diff line change
@@ -26,30 +26,45 @@ tags:
26
26
27
27
<p>Each person takes <strong>exactly 1 second</strong> to buy a ticket. A person can only buy <strong>1 ticket at a time</strong> and has to go back to <strong>the end</strong> of the line (which happens <strong>instantaneously</strong>) in order to buy more tickets. If a person does not have any tickets left to buy, the person will <strong>leave </strong>the line.</p>
28
28
29
-
<p>Return <em>the <strong>time taken</strong> for the person at position </em><code>k</code><em> </em><strong><em>(0-indexed)</em> </strong><em>to finish buying tickets</em>.</p>
29
+
<p>Return the <strong>time taken</strong> for the person <strong>initially</strong> at position <strong>k</strong><strong> </strong>(0-indexed)to finish buying tickets.</p>
30
30
31
31
<p> </p>
32
32
<p><strongclass="example">Example 1:</strong></p>
33
33
34
-
<pre>
35
-
<strong>Input:</strong> tickets = [2,3,2], k = 2
36
-
<strong>Output:</strong> 6
37
-
<strong>Explanation:</strong>
38
-
- In the first pass, everyone in the line buys a ticket and the line becomes [1, 2, 1].
39
-
- In the second pass, everyone in the line buys a ticket and the line becomes [0, 1, 0].
40
-
The person at position 2 has successfully bought 2 tickets and it took 3 + 3 = 6 seconds.
41
-
</pre>
34
+
<divclass="example-block">
35
+
<p><strong>Input:</strong> <spanclass="example-io">tickets = [2,3,2], k = 2</span></p>
0 commit comments