Coder Social home page Coder Social logo

findtharun / dsa-central-101 Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 2.62 MB

This Repository Contains Various Approaches to Solving a Problem, Serves as a Guide to Preparing for Interviews

Java 100.00%
dsa-algorithm dsa-java interview-preparation problem-solving 101 interview-questions sde-sheet

dsa-central-101's Introduction

DSA Central 101

This Repository Contains Various Approaches to Solving a Problem, Serves as a Guide to Preparing for Interviews

How to Avoid TLE

  • Number of Elementary Operations that can be done in 1 Sec is 10^8. If your algorithm is achieving it in <=10^8 (Including Constraints), then we can use bruteforce approach to solve the problem.

Use the information in a question to your advantage! It will often implicitly tell you how efficient your algorithm should be to get full points. Consider the fact that a computer can run 108 iterations per second. You’re usually going to be given an array or string; call its size n. Note that you cannot be asked to come up with a solution better than O(n) in this case (even if one exists); the reason is that it takes linear time to input the test array itself! With that in mind,

  • If (n >= 10^4), aim for a O(n) or a O(n log n) solution.
  • If (n <= 10^3), aim for a O(n2) solution
  • I(n <= 10^2), aim for a O(n3) solution
  • If (n < 20), a O(2n) solution should be fine.

Time Complexities of Common Operations for Java Collections

Operation ArrayList LinkedList HashSet HashMap TreeMap
Access (get) O(1) O(n) N/A N/A O(log n)
Search (contains) O(n) O(n) O(1) O(1) O(log n)
Insert (add at end) O(1) O(1) O(1) O(1) O(log n)
Insert (add at specific index) O(n) O(n) N/A N/A O(log n)
Delete (remove at end) O(1) O(1) O(1) O(1) O(log n)
Delete (remove at specific index) O(n) O(n) N/A N/A O(log n)
Sort (using default comparator) O(n log n) O(n log n) N/A N/A O(n log n)
Sort (using custom comparator) O(n log n) O(n log n) N/A N/A O(n log n)
Count Occurrences O(n) O(n) O(n) O(n) O(n)
Synchronized View O(1) O(1) O(1) O(1) O(1)
Unmodifiable View O(1) O(1) O(1) O(1) O(1)

Note:

  • ArrayList and LinkedList are different implementations of the List interface.

  • HashSet, HashMap, and TreeMap are implementations of the Set and Map interfaces.

  • N/A indicates that the operation is not applicable for that particular data structure.

  • Synchronized View: Functions like Collections.synchronizedList(), Collections.synchronizedSet(), and Collections.synchronizedMap() return synchronized (thread-safe) views of the specified collections.

  • Unmodifiable View: Functions like Collections.unmodifiableList(), Collections.unmodifiableSet(), and Collections.unmodifiableMap() return unmodifiable views of the specified collections, making them read-only.

Best Resources for Preparation

Best Explanations(Theortical / Visually)

Best Problems Listed

Best Videos/Blogs for Learning Java

Best Tools / Sites for Understanding Algorithms and Problems

CheatSheets

dsa-central-101's People

Contributors

findtharun avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

nishantmane7781

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.