Skip to content

Commit 51cd377

Browse files
author
openset
committed
Update: daily
1 parent fdb3a0e commit 51cd377

File tree

7 files changed

+166
-3
lines changed

7 files changed

+166
-3
lines changed

problems/best-time-to-buy-and-sell-stock-ii/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
<strong>Explanation:</strong> In this case, no transaction is done, i.e. max profit = 0.</pre>
4545

4646
### Related Topics
47-
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
4847
[[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)]
48+
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
4949

5050
### Similar Questions
5151
1. [Best Time to Buy and Sell Stock](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock) (Easy)

problems/insertion-sort-list/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ With each iteration one element (red) is removed from the input data and inserte
4848
</pre>
4949

5050
### Related Topics
51-
[[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)]
5251
[[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)]
52+
[[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)]
5353

5454
### Similar Questions
5555
1. [Sort List](https://github.com/openset/leetcode/tree/master/problems/sort-list) (Medium)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-tree-from-leaf-values "Minimum Cost Tree From Leaf Values")
9+
                
10+
Next >
11+
12+
## 1131. Maximum of Absolute Value Expression (Medium)
13+
14+
<p>Given two arrays of integers with equal lengths, return the maximum value of:</p>
15+
16+
<p><code>|arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j|</code></p>
17+
18+
<p>where the maximum is taken over all <code>0 &lt;= i, j &lt; arr1.length</code>.</p>
19+
20+
<p>&nbsp;</p>
21+
<p><strong>Example 1:</strong></p>
22+
23+
<pre>
24+
<strong>Input:</strong> arr1 = [1,2,3,4], arr2 = [-1,4,5,6]
25+
<strong>Output:</strong> 13
26+
</pre>
27+
28+
<p><strong>Example 2:</strong></p>
29+
30+
<pre>
31+
<strong>Input:</strong> arr1 = [1,-2,-5,0,10], arr2 = [0,-2,-1,-7,-4]
32+
<strong>Output:</strong> 20
33+
</pre>
34+
35+
<p>&nbsp;</p>
36+
<p><strong>Constraints:</strong></p>
37+
38+
<ul>
39+
<li><code>2 &lt;= arr1.length == arr2.length &lt;= 40000</code></li>
40+
<li><code>-10^6 &lt;= arr1[i], arr2[i] &lt;= 10^6</code></li>
41+
</ul>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-path-with-alternating-colors "Shortest Path with Alternating Colors")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-of-absolute-value-expression "Maximum of Absolute Value Expression")
11+
12+
## 1130. Minimum Cost Tree From Leaf Values (Medium)
13+
14+
<p>Given an array <code>arr</code> of positive integers, consider all binary trees such that:</p>
15+
16+
<ul>
17+
<li>Each node has either 0 or 2 children;</li>
18+
<li>The values of <code>arr</code> correspond to the values of each&nbsp;<strong>leaf</strong> in an in-order traversal of the tree.&nbsp; <em>(Recall that a node is a leaf if and only if it has 0 children.)</em></li>
19+
<li>The value&nbsp;of each non-leaf node is equal to the product of the largest leaf value in its left and right subtree respectively.</li>
20+
</ul>
21+
22+
<p>Among all possible binary trees considered,&nbsp;return the smallest possible sum of the values of each non-leaf node.&nbsp; It is guaranteed this sum fits into a 32-bit integer.</p>
23+
24+
<p>&nbsp;</p>
25+
<p><strong>Example 1:</strong></p>
26+
27+
<pre>
28+
<strong>Input:</strong> arr = [6,2,4]
29+
<strong>Output:</strong> 32
30+
<strong>Explanation:</strong>
31+
There are two possible trees. The first has non-leaf node sum 36, and the second has non-leaf node sum 32.
32+
33+
24 24
34+
/ \ / \
35+
12 4 6 8
36+
/ \ / \
37+
6 2 2 4
38+
</pre>
39+
40+
<p>&nbsp;</p>
41+
<p><strong>Constraints:</strong></p>
42+
43+
<ul>
44+
<li><code>2 &lt;= arr.length &lt;= 40</code></li>
45+
<li><code>1 &lt;= arr[i] &lt;= 15</code></li>
46+
<li>It is guaranteed that the answer fits into a 32-bit signed integer (ie.&nbsp;it is less than <code>2^31</code>).</li>
47+
</ul>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/user-purchase-platform "User Purchase Platform")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-path-with-alternating-colors "Shortest Path with Alternating Colors")
11+
12+
## 1128. Number of Equivalent Domino Pairs (Easy)
13+
14+
<p>Given a list of <code>dominoes</code>,&nbsp;<code>dominoes[i] = [a, b]</code>&nbsp;is <em>equivalent</em> to <code>dominoes[j] = [c, d]</code>&nbsp;if and only if either (<code>a==c</code> and <code>b==d</code>), or (<code>a==d</code> and <code>b==c</code>) - that is, one domino can be rotated to be equal to another domino.</p>
15+
16+
<p>Return the number of pairs <code>(i, j)</code> for which <code>0 &lt;= i &lt; j &lt; dominoes.length</code>, and&nbsp;<code>dominoes[i]</code> is equivalent to <code>dominoes[j]</code>.</p>
17+
18+
<p>&nbsp;</p>
19+
<p><strong>Example 1:</strong></p>
20+
<pre><strong>Input:</strong> dominoes = [[1,2],[2,1],[3,4],[5,6]]
21+
<strong>Output:</strong> 1
22+
</pre>
23+
<p>&nbsp;</p>
24+
<p><strong>Constraints:</strong></p>
25+
26+
<ul>
27+
<li><code>1 &lt;= dominoes.length &lt;= 40000</code></li>
28+
<li><code>1 &lt;= dominoes[i][j] &lt;= 9</code></li>
29+
</ul>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-equivalent-domino-pairs "Number of Equivalent Domino Pairs")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-tree-from-leaf-values "Minimum Cost Tree From Leaf Values")
11+
12+
## 1129. Shortest Path with Alternating Colors (Medium)
13+
14+
<p>Consider a directed graph, with nodes labelled <code>0, 1, ..., n-1</code>.&nbsp; In this graph, each edge is either red or blue, and there could&nbsp;be self-edges or parallel edges.</p>
15+
16+
<p>Each <code>[i, j]</code> in <code>red_edges</code> denotes a red directed edge from node <code>i</code> to node <code>j</code>.&nbsp; Similarly, each <code>[i, j]</code> in <code>blue_edges</code> denotes a blue directed edge from node <code>i</code> to node <code>j</code>.</p>
17+
18+
<p>Return an array <code>answer</code>&nbsp;of length <code>n</code>,&nbsp;where each&nbsp;<code>answer[X]</code>&nbsp;is&nbsp;the length of the shortest path from node <code>0</code>&nbsp;to node <code>X</code>&nbsp;such that the edge colors alternate along the path (or <code>-1</code> if such a path doesn&#39;t exist).</p>
19+
20+
<p>&nbsp;</p>
21+
<p><strong>Example 1:</strong></p>
22+
<pre><strong>Input:</strong> n = 3, red_edges = [[0,1],[1,2]], blue_edges = []
23+
<strong>Output:</strong> [0,1,-1]
24+
</pre><p><strong>Example 2:</strong></p>
25+
<pre><strong>Input:</strong> n = 3, red_edges = [[0,1]], blue_edges = [[2,1]]
26+
<strong>Output:</strong> [0,1,-1]
27+
</pre><p><strong>Example 3:</strong></p>
28+
<pre><strong>Input:</strong> n = 3, red_edges = [[1,0]], blue_edges = [[2,1]]
29+
<strong>Output:</strong> [0,-1,-1]
30+
</pre><p><strong>Example 4:</strong></p>
31+
<pre><strong>Input:</strong> n = 3, red_edges = [[0,1]], blue_edges = [[1,2]]
32+
<strong>Output:</strong> [0,1,2]
33+
</pre><p><strong>Example 5:</strong></p>
34+
<pre><strong>Input:</strong> n = 3, red_edges = [[0,1],[0,2]], blue_edges = [[1,0]]
35+
<strong>Output:</strong> [0,1,1]
36+
</pre>
37+
<p>&nbsp;</p>
38+
<p><strong>Constraints:</strong></p>
39+
40+
<ul>
41+
<li><code>1 &lt;= n &lt;= 100</code></li>
42+
<li><code>red_edges.length &lt;= 400</code></li>
43+
<li><code>blue_edges.length &lt;= 400</code></li>
44+
<li><code>red_edges[i].length == blue_edges[i].length == 2</code></li>
45+
<li><code>0 &lt;= red_edges[i][j], blue_edges[i][j] &lt; n</code></li>
46+
</ul>

problems/sort-list/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
<strong>Output:</strong> -1-&gt;0-&gt;3-&gt;4-&gt;5</pre>
2828

2929
### Related Topics
30-
[[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)]
3130
[[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)]
31+
[[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)]
3232

3333
### Similar Questions
3434
1. [Merge Two Sorted Lists](https://github.com/openset/leetcode/tree/master/problems/merge-two-sorted-lists) (Easy)

0 commit comments

Comments
 (0)