add note on 2d arrays

This commit is contained in:
marina 2023-07-31 18:20:46 -07:00 committed by GitHub
parent 8c631c5cd0
commit 0cd3198d05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,37 @@
## arrays and strings
<br>
### comparing strings
<br>
* "==" can be used to compare two strings only if the language support operator overloading (like C++).
<br>
----
### two-pointer technique
<br>
* a typical scenario is when you want to iterate the array from two ends to the middle.
* another secnario is when you need one slow-runner and one fast-runner at the same time (so that you can determine the movement strategy for both pointers).
* in any case, this technique is usually used when the array is sorted.
<br>
---
### two-dimensional arrays
<br>
* in some languages (like C++), 2d arrays are represented as 1d, so an array of `m * n` elements represents `array[i][j]` as `array[i * n + j]`.
* dynamic 2d arrays a nested dynamic array.
<br>
---