Skip to content

Commit 0722a3b

Browse files
committed
clean
1 parent 42378ba commit 0722a3b

31 files changed

+105
-106
lines changed

134.CanCompleteCircuit.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// 134. Gas Station
22
// There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i].
3-
// You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from the ith station to its next (i + 1)th station. You begin the journey with an empty tank at one of the gas stations.
4-
// 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
3+
// You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from the ith station to its next
4+
// (i + 1)th station. You begin the journey with an empty tank at one of the gas stations.
5+
// Given two integer arrays gas and cost, return the starting gas station's index if you can travel around the circuit
6+
// once in the clockwise direction, otherwise return -1. If there exists a solution, it is guaranteed to be unique
57
// Example 1:
68
// Input: gas = [1,2,3,4,5], cost = [3,4,5,1,2]
79
// Output: 3

138.CopyRandomList.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
// 138. Copy List with Random Pointer
22

3-
// A linked list of length n is given such that each node contains an additional random pointer, which could point to any node in the list, or null.
4-
// Construct a deep copy of the list. The deep copy should consist of exactly n brand new nodes, where each new node has its value set to the value of its corresponding original node. Both the next and random pointer of the new nodes should point to new nodes in the copied list such that the pointers in the original list and copied list represent the same list state. None of the pointers in the new list should point to nodes in the original list.
5-
// For example, if there are two nodes X and Y in the original list, where X.random --> Y, then for the corresponding two nodes x and y in the copied list, x.random --> y.
3+
// A linked list of length n is given such that each node contains an additional random pointer, which could point to any node
4+
// in the list, or null.
5+
// Construct a deep copy of the list. The deep copy should consist of exactly n brand new nodes, where each new node has its
6+
// value set to the value of its corresponding original node. Both the next and random pointer of the new nodes should point
7+
// to new nodes in the copied list such that the pointers in the original list and copied list represent the same list state.
8+
// None of the pointers in the new list should point to nodes in the original list.
9+
// For example, if there are two nodes X and Y in the original list, where X.random --> Y, then for the corresponding two nodes
10+
// x and y in the copied list, x.random --> y.
611
// Return the head of the copied linked list.
7-
// The linked list is represented in the input/output as a list of n nodes. Each node is represented as a pair of [val, random_index] where:
12+
// The linked list is represented in the input/output as a list of n nodes. Each node is represented as a pair of
13+
// [val, random_index] where:
814
// val: an integer representing Node.val
915
// random_index: the index of the node (range from 0 to n-1) that the random pointer points to, or null if it does not point to any node.
1016
// Your code will only be given the head of the original linked list.

142.DetectCycle.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
11
// 142. Linked List Cycle II
2-
32
// Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null.
4-
5-
// There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected to (0-indexed). It is -1 if there is no cycle. Note that pos is not passed as a parameter.
6-
3+
// There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following
4+
// the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected to
5+
// (0-indexed). It is -1 if there is no cycle. Note that pos is not passed as a parameter.
76
// Do not modify the linked list.
87

9-
10-
118
// Example 1:
12-
13-
149
// Input: head = [3,2,0,-4], pos = 1
1510
// Output: tail connects to node index 1
1611
// Explanation: There is a cycle in the linked list, where tail connects to the second node.
1712
// Example 2:
18-
19-
2013
// Input: head = [1,2], pos = 0
2114
// Output: tail connects to node index 0
2215
// Explanation: There is a cycle in the linked list, where tail connects to the first node.
2316
// Example 3:
24-
25-
2617
// Input: head = [1], pos = -1
2718
// Output: no cycle
2819
// Explanation: There is no cycle in the linked list.

146.LRUCache.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,12 @@
99
// void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key.
1010
// The functions get and put must each run in O(1) average time complexity.
1111

12-
13-
1412
// Example 1:
15-
1613
// Input
1714
// ["LRUCache", "put", "put", "get", "put", "get", "put", "get", "get", "get"]
1815
// [[2], [1, 1], [2, 2], [1], [3, 3], [2], [4, 4], [1], [3], [4]]
1916
// Output
2017
// [null, null, null, 1, null, -1, null, -1, 3, 4]
21-
2218
// Explanation
2319
// LRUCache lRUCache = new LRUCache(2);
2420
// lRUCache.put(1, 1); // cache is {1=1}

149.MaxPoints.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// 149. Max Points on a Line
2-
// Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line.
2+
// Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of
3+
// points that lie on the same straight line.
34
// Example 1:
45
// Input: points = [[1,1],[2,2],[3,3]]
56
// Output: 3

150.EvalRPN.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// Evaluate the value of an arithmetic expression in Reverse Polish Notation.
33
// Valid operators are +, -, *, and /. Each operand may be an integer or another expression.
44
// Note that division between two integers should truncate toward zero.
5-
// 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.
5+
// It is guaranteed that the given RPN expression is always valid. That means the expression would always evaluate to a result,
6+
// and there will not be any division by zero operation.
67
// Example 1:
78
// Input: tokens = ["2","1","+","3","*"]
89
// Output: 9

153.FindMin.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// 153. Find Minimum in Rotated Sorted Array
2-
// Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become:
2+
// Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array
3+
// nums = [0,1,2,4,5,6,7] might become:
34
// [4,5,6,7,0,1,2] if it was rotated 4 times.
45
// [0,1,2,4,5,6,7] if it was rotated 7 times.
5-
// Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the array [a[n-1], a[0], a[1], a[2], ..., a[n-2]].
6+
// Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the array
7+
// [a[n-1], a[0], a[1], a[2], ..., a[n-2]].
68
// Given the sorted rotated array nums of unique elements, return the minimum element of this array.
79
// You must write an algorithm that runs in O(log n) time.
810
// Example 1:

154.FindMin.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// 154. Find Minimum in Rotated Sorted Array II
2-
// Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,4,4,5,6,7] might become:
2+
// Suppose an array of length n sorted in ascending order is rotated between 1 and n times.
3+
// For example, the array nums = [0,1,4,4,5,6,7] might become:
34
// [4,5,6,7,0,1,4] if it was rotated 4 times.
45
// [0,1,4,4,5,6,7] if it was rotated 7 times.
5-
// Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the array [a[n-1], a[0], a[1], a[2], ..., a[n-2]].
6+
// Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the array
7+
// [a[n-1], a[0], a[1], a[2], ..., a[n-2]].
68
// Given the sorted rotated array nums that may contain duplicates, return the minimum element of this array.
79
// You must decrease the overall operation steps as much as possible.
810
// Example 1:

155.MinStack.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
// int getMin() retrieves the minimum element in the stack.
1212
// You must implement a solution with O(1) time complexity for each function.
1313

14-
15-
1614
// Example 1:
17-
1815
// Input
1916
// ["MinStack","push","push","push","getMin","pop","top","getMin"]
2017
// [[],[-2],[0],[-3],[],[],[],[]]

160.GetIntersectionNode.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// 160. Intersection of Two Linked Lists
22

3-
// Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null.
3+
// Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect.
4+
// If the two linked lists have no intersection at all, return null.
45
// For example, the following two linked lists begin to intersect at node c1:
56

67
// The test cases are generated such that there are no cycles anywhere in the entire linked structure.

0 commit comments

Comments
 (0)