Skip to content

Commit bcd17f2

Browse files
authored
Update and rename 3010-divide an array into subarrays with minimum cost 1.md to 3010-divide-an-array-into-subarrays-with-minimum-cost-i.md
1 parent 28553a8 commit bcd17f2

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

dsa-solutions/lc-solutions/3000-3099/3010-divide an array into subarrays with minimum cost 1.md renamed to dsa-solutions/lc-solutions/3000-3099/3010-divide-an-array-into-subarrays-with-minimum-cost-i.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
id: divide-an-array-into-subarrays-with-minimum-cost-I
2+
id: divide-an-array-into-subarrays-with-minimum-cost-i
33
title: Divide an Array Into Subarrays With Minimum Cost I
44
sidebar_label: 3010 -Divide an Array Into Subarrays With Minimum Cost I
55
tags:
@@ -15,9 +15,7 @@ You are given an array of integers nums of length n.
1515

1616
The cost of an array is the value of its first element. For example, the cost of [1,2,3] is 1 while the cost of [3,4,1] is 3.
1717

18-
You need to divide nums into 3 disjoint contiguous
19-
subarrays
20-
.
18+
You need to divide nums into 3 disjoint contiguous subarrays.
2119

2220
Return the minimum possible sum of the cost of these subarrays.
2321

@@ -64,7 +62,7 @@ It can be shown that 12 is the minimum cost achievable.
6462

6563
### Intuition
6664

67-
cost = nums[0] + smallest ele + 2nd smallest ele
65+
cost = nums[0] + smallest + 2nd smallest
6866

6967
Explanation
7068
You have to divide array in 3 parts think of making 2 slice/cuts in array. No matter how you cut the array, first part of array will always come, cost of 1st part will be nums[0] and it will always be added. So nums[0]is fixed.
@@ -148,14 +146,6 @@ public:
148146

149147
#### Complexity Analysis
150148

151-
- Time complexity:
152-
$O(n)$
153-
We only traverse through the array once
154-
155-
- Space complexity:
156-
$O(1)$
157-
Since we just have 2 pointers
158-
159-
- **LeetCode Problem**: [ Count Elements With Maximum Frequency](https://leetcode.com/problems/find-beautiful-indices-in-the-given-array-i/description/)
149+
- Time complexity: $O(n)$ We only traverse through the array once
160150

161-
- **Solution Link**: [LeetCode Solution](https://leetcode.com/problems/divide-an-array-into-subarrays-with-minimum-cost-i/solutions/4609507/simple-and-concise-solution)
151+
- Space complexity: $O(1)$ Since we just have 2 pointers

0 commit comments

Comments
 (0)