diff --git a/problems/best-time-to-buy-and-sell-stock-ii/README.md b/problems/best-time-to-buy-and-sell-stock-ii/README.md index 4257b8cc1..a379f0e32 100644 --- a/problems/best-time-to-buy-and-sell-stock-ii/README.md +++ b/problems/best-time-to-buy-and-sell-stock-ii/README.md @@ -44,8 +44,8 @@ Explanation: In this case, no transaction is done, i.e. max profit = 0. ### Related Topics - [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)] + [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] ### Similar Questions 1. [Best Time to Buy and Sell Stock](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock) (Easy) diff --git a/problems/insertion-sort-list/README.md b/problems/insertion-sort-list/README.md index 72eff798a..ccb768d9d 100644 --- a/problems/insertion-sort-list/README.md +++ b/problems/insertion-sort-list/README.md @@ -48,8 +48,8 @@ With each iteration one element (red) is removed from the input data and inserte ### Related Topics - [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)] + [[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] ### Similar Questions 1. [Sort List](https://github.com/openset/leetcode/tree/master/problems/sort-list) (Medium) diff --git a/problems/maximum-of-absolute-value-expression/README.md b/problems/maximum-of-absolute-value-expression/README.md new file mode 100644 index 000000000..5d16b18b8 --- /dev/null +++ b/problems/maximum-of-absolute-value-expression/README.md @@ -0,0 +1,41 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-tree-from-leaf-values "Minimum Cost Tree From Leaf Values") + +Next > + +## 1131. Maximum of Absolute Value Expression (Medium) + +
Given two arrays of integers with equal lengths, return the maximum value of:
+ +|arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j|
where the maximum is taken over all 0 <= i, j < arr1.length.
+
Example 1:
+ ++Input: arr1 = [1,2,3,4], arr2 = [-1,4,5,6] +Output: 13 ++ +
Example 2:
+ ++Input: arr1 = [1,-2,-5,0,10], arr2 = [0,-2,-1,-7,-4] +Output: 20 ++ +
+
Constraints:
+ +2 <= arr1.length == arr2.length <= 40000-10^6 <= arr1[i], arr2[i] <= 10^6Given an array arr of positive integers, consider all binary trees such that:
arr correspond to the values of each leaf in an in-order traversal of the tree. (Recall that a node is a leaf if and only if it has 0 children.)Among all possible binary trees considered, return the smallest possible sum of the values of each non-leaf node. It is guaranteed this sum fits into a 32-bit integer.
+ ++
Example 1:
+ ++Input: arr = [6,2,4] +Output: 32 +Explanation: +There are two possible trees. The first has non-leaf node sum 36, and the second has non-leaf node sum 32. + + 24 24 + / \ / \ + 12 4 6 8 + / \ / \ +6 2 2 4 ++ +
+
Constraints:
+ +2 <= arr.length <= 401 <= arr[i] <= 152^31).Given a list of dominoes, dominoes[i] = [a, b] is equivalent to dominoes[j] = [c, d] if and only if either (a==c and b==d), or (a==d and b==c) - that is, one domino can be rotated to be equal to another domino.
Return the number of pairs (i, j) for which 0 <= i < j < dominoes.length, and dominoes[i] is equivalent to dominoes[j].
+
Example 1:
+Input: dominoes = [[1,2],[2,1],[3,4],[5,6]] +Output: 1 ++
+
Constraints:
+ +1 <= dominoes.length <= 400001 <= dominoes[i][j] <= 9Consider a directed graph, with nodes labelled 0, 1, ..., n-1. In this graph, each edge is either red or blue, and there could be self-edges or parallel edges.
Each [i, j] in red_edges denotes a red directed edge from node i to node j. Similarly, each [i, j] in blue_edges denotes a blue directed edge from node i to node j.
Return an array answer of length n, where each answer[X] is the length of the shortest path from node 0 to node X such that the edge colors alternate along the path (or -1 if such a path doesn't exist).
+
Example 1:
+Input: n = 3, red_edges = [[0,1],[1,2]], blue_edges = [] +Output: [0,1,-1] +
Example 2:
+Input: n = 3, red_edges = [[0,1]], blue_edges = [[2,1]] +Output: [0,1,-1] +
Example 3:
+Input: n = 3, red_edges = [[1,0]], blue_edges = [[2,1]] +Output: [0,-1,-1] +
Example 4:
+Input: n = 3, red_edges = [[0,1]], blue_edges = [[1,2]] +Output: [0,1,2] +
Example 5:
+Input: n = 3, red_edges = [[0,1],[0,2]], blue_edges = [[1,0]] +Output: [0,1,1] ++
+
Constraints:
+ +1 <= n <= 100red_edges.length <= 400blue_edges.length <= 400red_edges[i].length == blue_edges[i].length == 20 <= red_edges[i][j], blue_edges[i][j] < n