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
You have N gardens, labelled 1 to N. In each garden, you want to plant one of 4 types of flowers.
3
+
4
+
paths[i] = [x, y] describes the existence of a bidirectional path from garden x to garden y.
5
+
6
+
Also, there is no garden that has more than 3 paths coming into or leaving it.
7
+
8
+
Your task is to choose a flower type for each garden such that, for any two gardens connected by a path, they have different types of flowers.
9
+
10
+
Return any such a choice as an array answer, where answer[i] is the type of flower planted in the (i+1)-th garden. The flower types are denoted 1, 2, 3, or 4. It is guaranteed an answer exists.
11
+
12
+
13
+
14
+
Example 1:
15
+
16
+
Input: N = 3, paths = [[1,2],[2,3],[3,1]]
17
+
Output: [1,2,3]
18
+
Example 2:
19
+
20
+
Input: N = 4, paths = [[1,2],[3,4]]
21
+
Output: [1,2,1,2]
22
+
Example 3:
23
+
24
+
Input: N = 4, paths = [[1,2],[2,3],[3,4],[4,1],[1,3],[2,4]]
25
+
Output: [1,2,3,4]
26
+
27
+
28
+
Note:
29
+
30
+
1 <= N <= 10000
31
+
0 <= paths.size <= 20000
32
+
No garden has 4 or more paths coming into or leaving it.
Given an integer array A, you partition the array into (contiguous) subarrays of length at most K. After partitioning, each subarray has their values changed to become the maximum value of that subarray.
3
+
4
+
Return the largest sum of the given array after partitioning.
|1043|[Partition Array for Maximum Sum](https://leetcode.com/problems/partition-array-for-maximum-sum/)|[Python](./1000-1100q/1043.py)|Medium|
18
+
|1042|[Flower Planting With No Adjacent](https://leetcode.com/problems/flower-planting-with-no-adjacent)|[Python](./1000-1100q/1042.py)|Easy|
19
+
|1041|[Robot Bounded In Circle](https://leetcode.com/problems/robot-bounded-in-circle)|[Python](./1000-1100q/1041.py)|Easy|
17
20
|1039|[Minimum Score Triangulation of Polygon](https://leetcode.com/problems/minimum-score-triangulation-of-polygon)|[Python](./1000-1100q/1039.py)|Medium|
18
21
|1038|[Binary Search Tree to Greater Sum Tree](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/)|[Python](./1000-1100q/1038.py)|Medium|
0 commit comments