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

Commit35d93df

Browse files
authored
Updated tasks 134-169
1 parent187520f commit35d93df

File tree

12 files changed

+42
-52
lines changed

12 files changed

+42
-52
lines changed

‎src/main/java/g0101_0200/s0134_gas_station/readme.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ There are `n` gas stations along a circular route, where the amount of gas at th
66

77
You have a car with an unlimited gas tank and it costs`cost[i]` of gas to travel from the <code>i<sup>th</sup></code> station to its next <code>(i + 1)<sup>th</sup></code> station. You begin the journey with an empty tank at one of the gas stations.
88

9-
Given two integer arrays`gas` and`cost`, return_the starting gas station's index if you can travel around the circuit once in the clockwise direction, otherwise return_`-1`. If there exists a solution, it is**guaranteed** to be**unique**
9+
Given two integer arrays`gas` and`cost`, return_the starting gas station's index if you can travel around the circuit once in the clockwise direction, otherwise return_`-1`. If there exists a solution, it is**guaranteed** to be**unique**.
1010

1111
**Example 1:**
1212

@@ -41,7 +41,7 @@ Given two integer arrays `gas` and `cost`, return _the starting gas station's in
4141

4242
**Constraints:**
4343

44-
*`gas.length == n`
45-
*`cost.length == n`
44+
*`n == gas.length == cost.length`
4645
* <code>1 <= n <= 10<sup>5</sup></code>
47-
* <code>0 <= gas[i], cost[i] <= 10<sup>4</sup></code>
46+
* <code>0 <= gas[i], cost[i] <= 10<sup>4</sup></code>
47+
* The input is generated such that the answer is unique.

‎src/main/java/g0101_0200/s0136_single_number/readme.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ You must implement a solution with a linear runtime complexity and use only cons
1010

1111
**Input:** nums =[2,2,1]
1212

13-
**Output:** 1
13+
**Output:** 1
1414

1515
**Example 2:**
1616

1717
**Input:** nums =[4,1,2,1,2]
1818

19-
**Output:** 4
19+
**Output:** 4
2020

2121
**Example 3:**
2222

2323
**Input:** nums =[1]
2424

25-
**Output:** 1
25+
**Output:** 1
2626

2727
**Constraints:**
2828

‎src/main/java/g0101_0200/s0138_copy_list_with_random_pointer/readme.md‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,10 @@ Your code will **only** be given the `head` of the original linked list.
4141

4242
**Output:**[[3,null],[3,0],[3,null]]
4343

44-
**Example 4:**
45-
46-
**Input:** head =[]
47-
48-
**Output:**[]
49-
50-
**Explanation:** The given linked list is empty (null pointer), so return null.
51-
5244
**Constraints:**
5345

5446
*`0 <= n <= 1000`
55-
*`-10000 <= Node.val <=10000`
47+
*<code>-10<sup>4</sup> <= Node.val <=10<sup>4</sup></code>
5648
*`Node.random` is`null` or is pointing to some node in the linked list.
5749

5850
To solve the "Copy List with Random Pointer" problem in Java with a`Solution` class, we'll use a HashMap to maintain a mapping between the original nodes and their corresponding copied nodes. Below are the steps:

‎src/main/java/g0101_0200/s0150_evaluate_reverse_polish_notation/readme.md‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
Medium
44

5-
Evaluate the valueof an arithmetic expression in[Reverse Polish Notation](http://en.wikipedia.org/wiki/Reverse_Polish_notation).
5+
You are given an arrayofstrings`tokens` that representsan arithmetic expression in a[Reverse Polish Notation](http://en.wikipedia.org/wiki/Reverse_Polish_notation).
66

7-
Valid operators are`+`,`-`,`*`, and`/`. Each operand may be an integer or another expression.
7+
Evaluate the expression. Return_an integer that represents the value of the expression_.
88

9-
**Note** that division between two integers should truncate toward zero.
9+
**Note** that:
1010

11-
It is guaranteed that the given RPN expression is always valid. That means the expression would always evaluate to a result, and there will not be any division by zero operation.
11+
* The valid operators are`'+'`,`'-'`,`'*'`, and`'/'`.
12+
* Each operand may be an integer or another expression.
13+
* The division between two integers always**truncates toward zero**.
14+
* There will not be any division by zero.
15+
* The input represents a valid arithmetic expression in a reverse polish notation.
16+
* The answer and all the intermediate calculations can be represented in a**32-bit** integer.
1217

1318
**Example 1:**
1419

‎src/main/java/g0101_0200/s0151_reverse_words_in_a_string/readme.md‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ Return _a string of the words in reverse order concatenated by a single space._
3232

3333
**Explanation:** You need to reduce multiple spaces between two words to a single space in the reversed string.
3434

35-
**Example 4:**
36-
37-
**Input:** s = " Bob Loves Alice "
38-
39-
**Output:** "Alice Loves Bob"
40-
41-
**Example 5:**
42-
43-
**Input:** s = "Alice does not even like bob"
44-
45-
**Output:** "bob like even not does Alice"
46-
4735
**Constraints:**
4836

4937
* <code>1 <= s.length <= 10<sup>4</sup></code>

‎src/main/java/g0101_0200/s0152_maximum_product_subarray/readme.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
Medium
44

5-
Given an integer array`nums`, find acontiguousnon-emptysubarray within the array that has the largest product, and return_the product_.
5+
Given an integer array`nums`, find a**non-emptysubarrays** that has the largest product, and return_the product_.
66

7-
It is**guaranteed** that the answer will fit in a**32-bit** integer.
7+
The test cases are generated so that the answer will fit in a**32-bit** integer.
88

9-
A**subarray**is a contiguous subsequence of thearray.
9+
**Note**that the product of an array with a single element is thevalue of that element.
1010

1111
**Example 1:**
1212

@@ -28,4 +28,4 @@ A **subarray** is a contiguous subsequence of the array.
2828

2929
* <code>1 <= nums.length <= 2 * 10<sup>4</sup></code>
3030
*`-10 <= nums[i] <= 10`
31-
* The product of anyprefix or suffix of`nums` is**guaranteed** to fit in a**32-bit** integer.
31+
* The product of anysubarray of`nums` is**guaranteed** to fit in a**32-bit** integer.

‎src/main/java/g0101_0200/s0153_find_minimum_in_rotated_sorted_array/readme.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Notice that **rotating** an array `[a[0], a[1], a[2], ..., a[n-1]]` 1 time resul
1111

1212
Given the sorted rotated array`nums` of**unique** elements, return_the minimum element of this array_.
1313

14-
You must write an algorithm that runs in`O(log n) time.`
14+
You must write an algorithm that runs in`O(log n) time`.
1515

1616
**Example 1:**
1717

‎src/main/java/g0101_0200/s0155_min_stack/readme.md‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
155\. Min Stack
22

3-
Easy
3+
Medium
44

55
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
66

@@ -12,12 +12,11 @@ Implement the `MinStack` class:
1212
*`int top()` gets the top element of the stack.
1313
*`int getMin()` retrieves the minimum element in the stack.
1414

15-
**Example 1:**
15+
You must implement a solution with`O(1)` time complexity for each function.
1616

17-
**Input**
17+
**Example 1:**
1818

19-
["MinStack","push","push","push","getMin","pop","top","getMin"]
20-
[[],[-2],[0],[-3],[],[],[],[]]
19+
**Input**["MinStack","push","push","push","getMin","pop","top","getMin"][[],[-2],[0],[-3],[],[],[],[]]
2120

2221
**Output:**[null,null,null,null,-3,null,0,-2]
2322

‎src/main/java/g0101_0200/s0160_intersection_of_two_linked_lists/readme.md‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ The judge will then create the linked structure based on these inputs and pass t
3232

3333
**Output:** Intersected at '8'
3434

35-
**Explanation:** The intersected node's value is 8 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as[4,1,8,4,5]. From the head of B, it reads as[5,6,1,8,4,5]. There are 2 nodes before the intersected node in A; There are 3 nodes before the intersected node in B.
35+
**Explanation:** The intersected node's value is 8 (note that this must not be 0 if the two lists intersect).
36+
37+
From the head of A, it reads as[4,1,8,4,5]. From the head of B, it reads as[5,6,1,8,4,5]. There are 2 nodes before the intersected node in A; There are 3 nodes before the intersected node in B.
38+
39+
- Note that the intersected node's value is not 1 because the nodes with value 1 in A and B (2<sup>nd</sup> node in A and 3<sup>rd</sup> node in B) are different node references. In other words, they point to two different locations in memory, while the nodes with value 8 in A and B (3<sup>rd</sup> node in A and 4<sup>th</sup> node in B) point to the same location in memory.
3640

3741
**Example 2:**
3842

@@ -58,11 +62,11 @@ The judge will then create the linked structure based on these inputs and pass t
5862

5963
* The number of nodes of`listA` is in the`m`.
6064
* The number of nodes of`listB` is in the`n`.
61-
* <code>0 <= m, n <= 3 * 10<sup>4</sup></code>
65+
* <code>1 <= m, n <= 3 * 10<sup>4</sup></code>
6266
* <code>1 <= Node.val <= 10<sup>5</sup></code>
6367
*`0 <= skipA <= m`
6468
*`0 <= skipB <= n`
6569
*`intersectVal` is`0` if`listA` and`listB` do not intersect.
6670
*`intersectVal == listA[skipA] == listB[skipB]` if`listA` and`listB` intersect.
6771

68-
**Follow up:** Could you write a solution that runs in`O(n)` time and use only`O(1)` memory?
72+
**Follow up:** Could you write a solution that runs in`O(m +n)` time and use only`O(1)` memory?

‎src/main/java/g0101_0200/s0162_find_peak_element/readme.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Medium
44

55
A peak element is an element that is strictly greater than its neighbors.
66

7-
Givenan integer array`nums`, find a peak element, and return its index. If the array contains multiple peaks, return the index to**any of the peaks**.
7+
Givena**0-indexed** integer array`nums`, find a peak element, and return its index. If the array contains multiple peaks, return the index to**any of the peaks**.
88

9-
You may imagine that`nums[-1] = nums[n] = -∞`.
9+
You may imagine that`nums[-1] = nums[n] = -∞`. In other words, an element is always considered to be strictly greater than a neighbor that is outside the array.
1010

1111
You must write an algorithm that runs in`O(log n)` time.
1212

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp