vault backup: 2022-09-05 16:10:30
This commit is contained in:
parent
57003c9601
commit
e3bff4cb79
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"obsidian-prism-theme@@color-schemes-lt": "pt-color-scheme-periwinkle-lt",
|
"obsidian-prism-theme@@color-schemes-lt": "pt-color-scheme-pistachio-lt",
|
||||||
"obsidian-prism-theme@@light-accent-color-preset": "pt-accent-color-purple-lt",
|
"obsidian-prism-theme@@light-accent-color-preset": "pt-accent-color-green-lt",
|
||||||
"obsidian-prism-theme@@color-schemes-dt": "pt-color-scheme-indigo-dt",
|
"obsidian-prism-theme@@color-schemes-dt": "pt-color-scheme-indigo-dt",
|
||||||
"obsidian-prism-theme@@pt-disable-blur": true,
|
"obsidian-prism-theme@@pt-disable-blur": true,
|
||||||
"obsidian-prism-theme@@pt-disable-animations": true,
|
"obsidian-prism-theme@@pt-disable-animations": true,
|
||||||
|
|
|
@ -33,6 +33,12 @@ This is where I store notes about CS
|
||||||
#CS_list_need_practicing
|
#CS_list_need_practicing
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Topics that needs care
|
||||||
|
|
||||||
|
- #sliding_window
|
||||||
|
- #Kadane_s_algorithm
|
||||||
|
- #greedy
|
||||||
|
|
||||||
## Websites
|
## Websites
|
||||||
|
|
||||||
#### [leetcode.com](https://leetcode.com)
|
#### [leetcode.com](https://leetcode.com)
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
> ##### Algorithms:
|
> ##### Algorithms:
|
||||||
>
|
>
|
||||||
> #algorithm #sliding_window #hash_table
|
> #algorithm #hash_table
|
||||||
>
|
>
|
||||||
> ##### Data structures:
|
> ##### Data structures:
|
||||||
>
|
>
|
||||||
> #DS
|
> #DS #array
|
||||||
>
|
>
|
||||||
> ##### Difficulty:
|
> ##### Difficulty:
|
||||||
>
|
>
|
||||||
|
@ -55,13 +55,16 @@ A subarray is a contiguous **non-empty** sequence of elements within an array.
|
||||||
### Thoughts
|
### Thoughts
|
||||||
|
|
||||||
> [!summary]
|
> [!summary]
|
||||||
> This can be solved using #sliding_window
|
> This can be solved using #prefix_sum and #hash_table
|
||||||
|
|
||||||
> I over-complicated the solution by adding stuff like
|
> I over-complicated the solution by adding stuff like
|
||||||
> sorting, but it turn out to be not so difficult.
|
> sorting, but it turn out to be not so difficult.
|
||||||
|
|
||||||
Since the subsets are **contiguous**, we can use sliding
|
> [!tip]
|
||||||
window here.
|
> Tried using sliding window, but it doesn't work because of
|
||||||
|
> negative numbers.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Solution
|
### Solution
|
||||||
|
|
||||||
|
@ -100,4 +103,4 @@ public:
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
|
@ -14,13 +14,14 @@
|
||||||
|
|
||||||
##### Difficulty:
|
##### Difficulty:
|
||||||
|
|
||||||
#CS_analysis #difficulty-
|
#CS_analysis
|
||||||
|
|
||||||
##### Related problems:
|
##### Related problems:
|
||||||
|
|
||||||
##### Links:
|
##### Links:
|
||||||
|
|
||||||
- [leetcode](https://leetcode.com/explore/learn/card/fun-with-arrays/511/in-place-operations/)
|
- [leetcode](https://leetcode.com/explore/learn/card/fun-with-arrays/511/in-place-operations/)
|
||||||
|
- [Two-pointers and sliding windows](https://leetcode.com/problems/subarray-sum-equals-k/discuss/301242/General-summary-of-what-kind-of-problem-can-cannot-solved-by-Two-Pointers)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -35,3 +36,9 @@ By using two pointers, to in place modify array elements.
|
||||||
|
|
||||||
- There are two arrays, or linked lists
|
- There are two arrays, or linked lists
|
||||||
- They are sorted, or operation in place will not interfere elements after.
|
- They are sorted, or operation in place will not interfere elements after.
|
||||||
|
|
||||||
|
### When not use it?
|
||||||
|
|
||||||
|
Refer to [this link](https://leetcode.com/problems/subarray-sum-equals-k/discuss/301242/General-summary-of-what-kind-of-problem-can-cannot-solved-by-Two-Pointers)
|
||||||
|
|
||||||
|
#TODO: complete this section
|
Loading…
Reference in a new issue