0% found this document useful (0 votes)
41 views2 pages

Tips To Solve Any DSA Question by Understanding Patterns

Uploaded by

swetalj7011
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views2 pages

Tips To Solve Any DSA Question by Understanding Patterns

Uploaded by

swetalj7011
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Tips To Solve Any DSA Question By

Understanding Patterns

If input array is sorted then


- Binary search
- Two pointers

If asked for all permutations/subsets then


- Backtracking

If given a tree then


- DFS
- BFS

If given a graph then


- DFS
- BFS

If given a linked list then


- Two pointers

If recursion is banned then


- Stack

If must solve in-place then


- Swap corresponding values
- Store one or more different values in the same pointer

If asked for maximum/minimum subarray/subset/options then

Follow Pratham Kohli for more!


- Dynamic programming

If asked for top/least K items then


- Heap
- QuickSelect

If asked for common strings then


- Map
- Trie

Else
- Map/Set for O(1) time & O(n) space
- Sort input for O(nlogn) time and O(1) space

Ques: Want all the resources and roadmaps at one place ?

Then checkout this 100+ page guide I created with a proper roadmap and all the resources that
you will need!

Note: This guide is Only for Working Professionals Looking to SWITCH, NOT for Students!

Link: https://topmate.io/prathamkohli/883051

Note : A lot more exciting content is scheduled to come on Instagram.


We will dive deep into each resource for DSA, LLD, HLD, Resume Preparation and a lot
more to make you job ready by the end of 2024!
Do stay tuned on Instagram at : @prathamkohliyt

Follow Pratham Kohli for more!

You might also like