Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The trick to single pass array problems, and more #17

Open
sanjarcode opened this issue Oct 12, 2022 · 1 comment
Open

The trick to single pass array problems, and more #17

sanjarcode opened this issue Oct 12, 2022 · 1 comment

Comments

@sanjarcode
Copy link
Member

sanjarcode commented Oct 12, 2022

Copying from activity_logger

All single pass 1D array problems rely on the "knowing" what has happened in the past - i.e possibility of creating a fast lookup structure for the till-seen part of the array.

This fast lookup structure may be a number (e.g. in case of Kadane's algorithm) or a hashmap or a heap, anything.

Approximately, this should takeo(n) space and/or o(n) lookup time (small O notation).

If this is not possible - i.e. one cannot create a structure at all or it exceeds the said bound, two (or more) loops are inevitable.

*more than one loop is inevitable

This thinking could be extended to more dimensional structures like n-dimensional arrays or trees or graphs or a combination.

Why this might work - noob level information theory

@sanjarcode
Copy link
Member Author

sanjarcode commented Oct 12, 2022

Screenshot_20221013-012009_WhatsApp.png

*algorithm design for some problems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant