- https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
- Also check out my previous posts on:

**Deployments** manage the deployment and scaling of a set of Pods and provide declarative updates to applications.

- A Deployment is described as
**a set of identical Pods**with no unique identities. A Deployment runs multiple replicas of your application and automatically replaces any instances that fail or become unresponsive. - In essence, Deployments are
**higher-level concepts**that manage ReplicaSets and provide additional features like**rolling updates and rollbacks**. - As such, it’s recommended to use Deployment instead of directly managing ReplicaSets because it provides additional useful features.
- Deployments manage
**stateless**applications, while StatefulSets manage**stateful**applications

- Simple example of Deployment yaml definition, you will find this very similar to ReplicaSet
`apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx spec: strategy: # how to replace old pods with new ones type: RollingUpdate # default strategy rollingUpdate: maxUnavailable: 1 maxSurge: 1 replicas: 3 # number of replica pods selector: matchLabels: app: nginx # selector template: # pod template (just like what we would define in pod yaml) metadata: labels: app: nginx # label of pod spec: containers: - name: nginx image: nginx:1.14.2`

- Get deployment details

`k get deploy <deployment-name> -o wide`

- Update Deployment replicas

`k scale deployment <deployment-name> --replicas=<num>`

- Rollback to an earlier Deployment revision

`k rollout undo deploy <deployment-name>`

- View the rollout history of a Deployment

`k rollout history deploy <deployment-name>`

- Determine Deployment (owner) of a pod

`k get pods <pod-name> -o yaml | grep -A 5 owner`

- Delete Deployment and all its pods

`k delete deploy <deployment-name>`

- Delete Deployment only

`k delete deploy <deployment-name> --cascade=orphan`

`s0`

and `s1`

, return the number of substrings where `s1`

contains any anagram of `s0`

.
**Constraints**

`n ≤ 100,000`

where`n`

is the length of`s0`

`m ≤ 100,000`

where`m`

is the length of`s1`

https://binarysearch.com/problems/Anagram-Substrings

**Input**

- s0 =
`abc`

- s1 =
`bcabxabc`

**Output**

- answer =
`3`

**Explanation**

The substrings `"bca"`

, `"cab"`

and `"abc"`

of `s0`

are permutations of `"abc"`

.

`n`

and a two-dimensional list of integers `enemies`

. Integer `n`

means there’s `n`

people labeled from `[0, n - 1]`

. Each element in `enemies`

contains `[person_a, person_b]`

which means that `person_a`

and `person_b`

are enemies.
Return whether it’s possible to partition the `n`

people into two groups such that no two people that are enemies are in the same group.

**Constraints**

`n ≤ 1,000`

`m ≤ 10,000`

where`m`

is the length of`enemies`

https://binarysearch.com/problems/Separate-People-Given-Dislike-Relations

**Input**

- n =
`4`

- enemies =

```
[[0,1],
[1,2]]
```

**Output**

- answer =
`True`

**Explanation**

We can have these two groups `[0, 2, 3]`

and `[1]`

.

**Input**

- n =
`3`

- enemies =

```
[[0,1],
[0,2],
[1,2]]
```

**Output**

- answer =
`False`

**Explanation**

No matter how we split the two groups, there will be two people that are enemies in a group.

`weights`

and `values`

which have the same length and an integer `capacity`

. `weights[i]`

and `values[i]`

represent the weight and value of the `i`

th item.
Given that you can take at most `capacity`

weights, and that you can take a fraction of an item’s weight with proportionate value, return the maximum amount of value you can get, rounded down to the nearest integer.

**Constraints**

`n ≤ 100,000`

where`n`

is the length of`weights`

and`values`

https://binarysearch.com/problems/Fractional-Knapsack

**Input**

- weights =
`[5, 6, 2]`

- values =
`[100, 100, 1]`

- capacity =
`8`

**Output**

- answer =
`150`

**Explanation**

The best we can do is:

- Take the item with
`5`

weight and take the`100`

value, leaving us with`3`

capacity - Take half of the item with
`6`

weight and take half of the`100`

value.

**Input**

- weights =
`[5, 6, 2]`

- values =
`[100, 100, 1]`

- capacity =
`13`

**Output**

- answer =
`201`

**Explanation**

We can take all `3`

items in full

`nums`

and an integer `diff`

, return the length of the longest arithmetic subsequence where the difference between each consecutive numbers in the subsequence is `diff`

.
**Constraints**

`0 ≤ n ≤ 100,000`

where`n`

is the length of`nums`

https://binarysearch.com/problems/Longest-Arithmetic-Subsequence-with-Difference-Constraint

**Input**

- nums =
`[-2, 0, 3, 6, 1, 9]`

- diff =
`3`

**Output**

- answer =
`4`

**Explanation**

We can pick the subsequence `[0, 3, 6, 9]`

.

**Input**

- nums =
`[9, 8, 7, 5, 3]`

- diff =
`-2`

**Output**

- answer =
`4`

**Explanation**

We can pick the subsequence `[9, 7, 5, 3]`

.

`matrix`

and an integer `k`

, return the largest sum of a rectangle `≤ k`

.
**Constraints**

`n, m ≤ 100`

where`n`

and`m`

are the number of rows and columns in`matrix`

.

https://binarysearch.com/problems/Maximum-Sum-Rectangle-with-Condition

**Input**

- matrix =

```
[[ 2,-2],
[ 3, 2]]
```

- k =
`6`

**Output**

- answer =
`5`

**Explanation**

We can take the rectangle `[2, 3]`

to get sum of `5`

.

`nums`

, rearrange its order to form the largest possible integer and return it as a string.
**Constraints**

`n ≤ 1,000`

where`n`

is the length of`nums`

`nums[i] ≤ 1,000`

https://binarysearch.com/problems/Create-Largest-Number-From-a-List

**Input**

- nums =
`[10, 7, 76, 415]`

**Output**

- answer =
`77641510`

**Input**

- nums =
`[961, 745, 331, 794, 923]`

**Output**

- answer =
`961923794745331`

**Input**

- nums =
`[45, 14, 70, 67, 95]`

**Output**

- answer =
`9570674514`

**Input**

- nums =
`[70, 5, 94, 18, 78]`

**Output**

- answer =
`947870518`

`nums`

, remove numbers that appear multiple times in the list, while maintaining order of the appearance in the original list.
It should use \(\mathcal{O}(k)\) space where `k`

is the number of unique integers.

**Constraints**

`n ≤ 100,000`

where`n`

is the length of`nums`

https://binarysearch.com/problems/Remove-Duplicate-Numbers

**Input**

- nums =
`[1, 3, 5, 0, 3, 5, 8]`

**Output**

- answer =
`[1, 0, 8]`

**Explanation**

Only [1, 0, 8] are unique in the list and that’s the order they appear in.

`matrix`

, find the length of the longest strictly increasing path. You can move up, down, left, or right.
**Constraints**

`n, m ≤ 500`

where`n`

and`m`

are the number of rows and columns in`matrix`

https://binarysearch.com/problems/Longest-Increasing-Path

**Input**

- matrix =

```
[[1,3,5],
[0,4,6],
[2,2,9]]
```

**Output**

- answer =
`6`

**Explanation**

The longest path is `[0, 1, 3, 5, 6, 9]`

`k`

and a list of integers `nums`

, return the length of the longest sublist that contains at most `k`

distinct integers.
**Constraints**

`0 ≤ k ≤ n ≤ 100,000`

where`n`

is the length of`nums`

https://binarysearch.com/problems/Longest-Sublist-with-K-Distinct-Numbers

**Input**

- k =
`1`

- nums =
`[0, 0, 0, 0, 0]`

**Output**

- answer =
`5`

**Input**

- k =
`2`

- nums =
`[0, 1, 2, 1, 0]`

**Output**

- answer =
`3`

**Explanation**

The longest substring with `2`

distinct integers is `[1,2,1]`

, which has length of `3`

.

**Input**

- k =
`1`

- nums =
`[0, 1, 2, 3, 4]`

**Output**

- answer =
`1`