Coding Interview Resources
51.6K subscribers
712 photos
7 files
410 links
This channel contains the free resources and solution of coding problems which are usually asked in the interviews.

Managed by: @love_data
Download Telegram
βœ… Top Programming Basics Interview Questions with Answers πŸ§ πŸ’»

1️⃣ What is a variable?
Answer:
A variable is a named container used to store data in a program. Its value can change during execution.
Example:
name = "Alice"
age = 25


2️⃣ What are data types?
Answer:
Data types define the kind of value a variable can hold. Common types:
– int: Integer (e.g., 5)
– float: Decimal (e.g., 3.14)
– char / str: Character or String
– bool: Boolean (True/False)

3️⃣ What are operators in programming?
Answer:
Operators perform operations on variables/values.
– Arithmetic: +, -, *, /
– Comparison: ==,!=, >, <
– Logical: &&, ||,! (or and, or, not)
– Assignment: =, +=, -=

4️⃣ What is type casting?
Answer:
Type casting means converting one data type to another.
Example (Python):
x = int("5")     # Converts string to integer


5️⃣ What is the purpose of comments in code?
Answer:
Comments are used to explain code. They're ignored during execution.
– Single-line: // comment or # comment
– Multi-line:
"""
This is a
multi-line comment
"""


6️⃣ How do you take input and display output?
Answer:
Python Example:
name = input("Enter your name: ")
print("Hello", name)

C++ Example:
cin >> name;
cout << "Hello " << name;


7️⃣ What is the difference between a statement and an expression?
Answer:
– Expression: Returns a value (e.g., 2 + 3)
– Statement: Performs an action (e.g., x = 5)

8️⃣ What is the difference between compile-time and run-time?
Answer:
– Compile-time: Errors detected before execution (e.g., syntax errors)
– Run-time: Errors during execution (e.g., divide by zero)

πŸ’¬ Double Tap ❀️ for more!
❀15
⚑ 25 Browser Extensions to Supercharge Your Coding Workflow πŸš€

βœ… JSON Viewer
βœ… Octotree (GitHub code tree)
βœ… Web Developer Tools
βœ… Wappalyzer (tech stack detector)
βœ… React Developer Tools
βœ… Redux DevTools
βœ… Vue js DevTools
βœ… Angular DevTools
βœ… ColorZilla
βœ… WhatFont
βœ… CSS Peeper
βœ… Axe DevTools (accessibility)
βœ… Page Ruler Redux
βœ… Lighthouse
βœ… Check My Links
βœ… EditThisCookie
βœ… Tampermonkey
βœ… Postman Interceptor
βœ… RESTED
βœ… GraphQL Playground
βœ… XPath Helper
βœ… Gitpod Browser Extension
βœ… Codeium for Chrome
βœ… TabNine Assistant
βœ… Grammarly (for cleaner docs & commits)

πŸ”₯ React ❀️ if you’re using at least one of these!
❀11πŸ₯°2
πŸ’‘ 10 Smart Programming Habits Every Developer Should Build πŸ‘¨β€πŸ’»πŸ§ 

1️⃣ Write clean, readable code
β†’ Code is read more often than it’s written. Clarity > cleverness.

2️⃣ Break big problems into small parts
β†’ Divide and conquer. Small functions are easier to debug and reuse.

3️⃣ Use meaningful commit messages
β†’ β€œFixed stuff” doesn’t help. Be specific: β€œFix null check on login form.”

4️⃣ Keep learning new tools & languages
β†’ Tech evolves fast. Stay curious and adaptable.

5️⃣ Write tests, even basic ones
β†’ Prevent future bugs. Start with simple unit tests.

6️⃣ Use a linter and formatter
β†’ Tools like ESLint, Black, or Prettier keep your code clean automatically.

7️⃣ Document your code
β†’ Write docstrings or inline comments to explain logic clearly.

8️⃣ Review your code before pushing
β†’ Catch silly mistakes early. Think of it as proofreading your code.

9️⃣ Optimize only when needed
β†’ First make it work, then make it fast.

πŸ”Ÿ Contribute to open source or side projects
β†’ Practice, network, and learn from real-world codebases.

πŸ’¬ Tap ❀️ if you found this helpful!
❀8
12 Websites to Learn Programming for FREEπŸ§‘β€πŸ’»

βœ… freecodecamp ❀️
βœ… javascript πŸ‘πŸ»
βœ… theodinproject πŸ‘πŸ»
βœ… stackoverflow 🫢🏻
βœ… geeksforgeeks 😍
βœ… khanacademy 🫣
βœ… javatpoint ⚑
βœ… codecademy 🫑
βœ… sololearn ✌🏻
βœ… programiz ⭐
βœ… w3school πŸ™ŒπŸ»
βœ… youtube πŸ₯°

Which one is your favourite!
Give reaction❀️
❀10πŸ₯°1
⚑️ 25 Browser Extensions to Supercharge Your Coding Workflow πŸš€

βœ… JSON Viewer
βœ… Octotree (GitHub code tree)
βœ… Web Developer Tools
βœ… Wappalyzer (tech stack detector)
βœ… React Developer Tools
βœ… Redux DevTools
βœ… Vue js DevTools
βœ… Angular DevTools
βœ… ColorZilla
βœ… WhatFont
βœ… CSS Peeper
βœ… Axe DevTools (accessibility)
βœ… Page Ruler Redux
βœ… Lighthouse
βœ… Check My Links
βœ… EditThisCookie
βœ… Tampermonkey
βœ… Postman Interceptor
βœ… RESTED
βœ… GraphQL Playground
βœ… XPath Helper
βœ… Gitpod Browser Extension
βœ… Codeium for Chrome
βœ… TabNine Assistant
βœ… Grammarly (for cleaner docs & commits)

πŸ”₯ React ❀️ if you’re using at least one of these!
❀7
βœ… DSA Interview Questions & Answers – Part 1 πŸ§ πŸ’»

1️⃣ What is a Data Structure?
A: A way to store and organize data for efficient access and modification. Examples: Array, Linked List, Stack, Queue, Tree, Graph.

2️⃣ What is the difference between Array and Linked List?
A:
⦁ Array: Fixed size, contiguous memory, fast random access (O(1)), slow insertion/deletion (O(n)).
⦁ Linked List: Dynamic size, nodes in memory connected via pointers, slower access (O(n)), fast insertion/deletion (O(1)) at head or tail.

3️⃣ What is a Stack? Give an example.
A: Stack is a linear data structure following LIFO (Last In First Out).
⦁ Operations: push, pop, peek
⦁ Example: Browser history, Undo functionality in editors.

4️⃣ What is a Queue? Difference between Queue & Stack?
A: Queue is a linear data structure following FIFO (First In First Out).
⦁ Stack: LIFO β†’ Last element added is first to remove.
⦁ Queue: FIFO β†’ First element added is first to remove.
⦁ Example: Print job scheduling, Task scheduling.

5️⃣ What is a Linked List? Types?
A: Linked List is a collection of nodes where each node contains data and a pointer to the next node.
⦁ Types:
⦁ Singly Linked List
⦁ Doubly Linked List
⦁ Circular Linked List

6️⃣ What is the difference between Stack and Heap memory?
A:
⦁ Stack: Stores local variables, function calls; LIFO; automatically managed; faster access.
⦁ Heap: Stores dynamic memory; managed manually or via garbage collection; slower access; flexible size.

7️⃣ What is a Hash Table?
A: A data structure that maps keys to values using a hash function for O(1) average-time access.
⦁ Example: Python dict, Java HashMap.
⦁ Collision Handling: Chaining, Open addressing.

8️⃣ What is the difference between BFS and DFS?
A:
⦁ BFS (Breadth-First Search): Level-wise traversal; uses Queue; finds shortest path in unweighted graphs.
⦁ DFS (Depth-First Search): Deep traversal using Stack/Recursion; uses less memory for sparse graphs.

9️⃣ What is a Binary Search Tree (BST)?
A: A tree where each node:
⦁ Left child < Node < Right child
⦁ Allows O(log n) search, insertion, and deletion on average.
⦁ Not necessarily balanced β†’ worst-case O(n).

πŸ”Ÿ What is Time Complexity?
A: Measure of the number of operations an algorithm takes relative to input size (n).
⦁ Examples:
⦁ O(1) β†’ Constant
⦁ O(n) β†’ Linear
⦁ O(log n) β†’ Logarithmic
⦁ O(nΒ²) β†’ Quadratic

πŸ’¬ Double Tap ❀️ if you found this helpful!
❀9
βœ… DSA Interview Questions & Answers – Part 2 πŸ§ πŸ’»

1️⃣ What is a Graph?
A: A non-linear data structure with nodes (vertices) connected by edges representing relationships.
⦁ Types: Directed (one-way edges, like Twitter follows), Undirected (bidirectional, like friendships), Weighted (edges with costs, e.g., distances), Unweighted.
⦁ Example: Social networks (users as nodes, connections as edges) or maps (cities and routes)β€”BFS/DFS traversal is key for shortest paths.

2️⃣ Difference between Tree and Graph?
A:
⦁ Tree: Acyclic (no loops), connected graph with exactly one path between nodes, hierarchical with a root and N-1 edges for N nodesβ€”great for file systems.
⦁ Graph: Can have cycles, multiple paths, disconnected components, and more edgesβ€”more flexible but needs cycle detection algorithms like DFS.

3️⃣ What is a Heap?
A: A complete binary tree satisfying the heap property for fast min/max access.
⦁ Max Heap: Parent nodes β‰₯ children (root is maximum).
⦁ Min Heap: Parent ≀ children (root is minimum).
⦁ Uses: Priority queues (e.g., task scheduling), Heap Sort (O(n log n))β€”implemented via arrays for efficiency.

4️⃣ What is Recursion? Example?
A: A technique where a function solves a problem by calling itself on smaller inputs until a base case stops it, using implicit stack.
⦁ Example: Factorial: def fact(n): return 1 if n <= 1 else n * fact(n-1). Also Fibonacci or tree traversalsβ€”watch for stack overflow on deep calls.

5️⃣ Difference between Recursion and Iteration?
A:
⦁ Recursion: Self-calling with base case, elegant for tree/graph problems but uses call stack (risk of overflow), O(n) space.
⦁ Iteration: Uses loops (for/while), explicit control, lower memory, faster executionβ€”convert recursion via tail optimization for interviews.

6️⃣ What is a Trie?
A: A prefix tree for storing strings in a tree where each node represents a character, enabling fast lookups and prefixes.
⦁ Use Case: Autocomplete (search engines), spell checkers, IP routingβ€”O(m) time for m-length word, space-efficient for common prefixes.

7️⃣ Difference between Linear Search & Binary Search?
A:
⦁ Linear Search: Scans sequentially, O(n) time, works on unsorted dataβ€”simple but inefficient for large lists.
⦁ Binary Search: Divides sorted array in half repeatedly, O(log n) timeβ€”requires sorted input, ideal for databases or sorted arrays.

8️⃣ What is a Circular Queue?
A: A queue implementation where the rear connects back to front, reusing space to avoid linear queue's "wasted" slots after dequeues.
⦁ Efficient memory usage (no shifting), fixed size, handles wrap-around with moduloβ€”common in buffering systems like OS task queues.

9️⃣ What is a Priority Queue?
A: An abstract data type where elements have priorities; dequeue removes highest/lowest priority first (not FIFO).
⦁ Implemented using: Heaps (binary for O(log n) insert/extract), also arrays or linked listsβ€”used in Dijkstra's algorithm or job scheduling.

πŸ”Ÿ What is Dynamic Programming (DP)?
A: An optimization technique for problems with overlapping subproblems and optimal substructure, solving bottom-up or top-down with memoization to avoid recomputation.
⦁ Example: Fibonacci (store fib(n-1) + fib(n-2)), 0/1 Knapsack (max value without exceeding weight)β€”reduces exponential to polynomial time.

πŸ’¬ Double Tap ❀️ if this helped you!
❀9
Big-O CheatsheetπŸ‘¨πŸ»β€πŸ’»πŸ“

React ❀️ for more like this
❀6πŸ‘Œ1
😁10
Step-by-step Guide to Create a Web Development Portfolio:

βœ… 1️⃣ Choose Your Tech Stack
Decide what type of web developer you are:
β€’ Frontend β†’ HTML, CSS, JavaScript, React
β€’ Backend β†’ Node.js, Express, Python (Django/Flask)
β€’ Full-stack β†’ Mix of both frontend + backend
β€’ Optional: Use tools like Git, GitHub, Netlify, Vercel

βœ… 2️⃣ Plan Your Portfolio Structure
Your site should include:
β€’ Home Page – Short intro about you
β€’ About Me – Skills, tools, background
β€’ Projects – Showcased with live links + GitHub
β€’ Contact – Email, LinkedIn, social media links
β€’ Optional: Blog section (for SEO & personal branding)

βœ… 3️⃣ Build the Portfolio Website
Use these options:
β€’ HTML/CSS/JS (for full control)
β€’ React or Vue (for interactive UI)
β€’ Use templates from GitHub for inspiration
β€’ Responsive design: Make sure it works on mobile too!

βœ… 4️⃣ Add 2–4 Strong Projects
Projects should be diverse and show your skills:
β€’ Personal website
β€’ Weather app, to-do list, blog, portfolio CMS
β€’ E-commerce or booking clone
β€’ API integration project

Each project should have:
β€’ Short description
β€’ Tech stack used
β€’ Live demo link
β€’ GitHub code link
β€’ Screenshots or GIFs

βœ… 5️⃣ Deploy Your Portfolio Online
Use free hosting platforms:
β€’ Netlify
β€’ GitHub Pages
β€’ Vercel
β€’ Render

βœ… 6️⃣ Keep It Updated
β€’ Add new projects
β€’ Keep links working
β€’ Fix any bugs
β€’ Write short blog posts if possible

πŸ’‘ Pro Tips
β€’ Make your site visually clean and simple
β€’ Add a downloadable resume
β€’ Link your GitHub and LinkedIn
β€’ Use a custom domain if possible (e.g., yourname.dev)

🎯 Goal: When someone visits your site, they should know who you are, what you do, and how to contact youβ€”all in under 30 seconds.

πŸ‘ Tap ❀️ if you found this helpful!
❀11
The program for the 10th AI Journey 2025 international conference has been unveiled: scientists, visionaries, and global AI practitioners will come together on one stage. Here, you will hear the voices of those who don't just believe in the futureβ€”they are creating it!

Speakers include visionaries Kai-Fu Lee and Chen Qufan, as well as dozens of global AI gurus from around the world!

On the first day of the conference, November 19, we will talk about how AI is already being used in various areas of life, helping to unlock human potential for the future and changing creative industries, and what impact it has on humans and on a sustainable future.

On November 20, we will focus on the role of AI in business and economic development and present technologies that will help businesses and developers be more effective by unlocking human potential.

On November 21, we will talk about how engineers and scientists are making scientific and technological breakthroughs and creating the future today!

Ride the wave with AI into the future!

Tune in to the AI Journey webcast on November 19-21.
❀2
πŸ§‘β€πŸ’» How to Crack Coding Interviews in 2025 πŸ’₯πŸš€

1️⃣ Understand the Interview Format
⦁ Phone screen, technical rounds, system design, behavioral
⦁ Research company-specific patterns on sites like Glassdoor

2️⃣ Master Data Structures & Algorithms
⦁ Arrays, Strings, Linked Lists, Trees, Graphs
⦁ Sorting, Searching, Recursion, Dynamic Programming
⦁ Practice daily on LeetCode, HackerRank, Codeforces

3️⃣ Learn Problem-Solving Patterns
⦁ Sliding window, Two pointers, Fast & slow pointers
⦁ Backtracking, Greedy, Divide & Conquer
⦁ Understand when & how to apply them

4️⃣ Write Clean & Efficient Code
⦁ Focus on readability, naming, and edge cases
⦁ Optimize time & space complexity
⦁ Explain your approach clearly during interviews

5️⃣ Mock Interviews & Peer Coding
⦁ Practice with friends or platforms like Pramp, Interviewing.io
⦁ Get comfortable thinking aloud and receiving feedback

6️⃣ Prepare for Behavioral Questions
⦁ Use STAR method (Situation, Task, Action, Result)
⦁ Highlight teamwork, problem-solving, and adaptability

7️⃣ Know Your Projects & Resume
⦁ Be ready to explain your role, challenges, and learnings
⦁ Discuss tech stack and decisions confidently

8️⃣ Stay Calm & Confident
⦁ Take a deep breath before coding
⦁ Think aloud, clarify doubts
⦁ It’s okay to ask for hints or discuss trade-offs

πŸ’¬ Double Tap ❀️ For More!
❀6πŸ‘1πŸ‘Œ1
Tune in to the 10th AI Journey 2025 international conference: scientists, visionaries, and global AI practitioners will come together on one stage. Here, you will hear the voices of those who don't just believe in the futureβ€”they are creating it!

Speakers include visionaries Kai-Fu Lee and Chen Qufan, as well as dozens of global AI gurus! Do you agree with their predictions about AI?

On the first day of the conference, November 19, we will talk about how AI is already being used in various areas of life, helping to unlock human potential for the future and changing creative industries, and what impact it has on humans and on a sustainable future.

On November 20, we will focus on the role of AI in business and economic development and present technologies that will help businesses and developers be more effective by unlocking human potential.

On November 21, we will talk about how engineers and scientists are making scientific and technological breakthroughs and creating the future today! The day's program includes presentations by scientists from around the world:
- Ajit Abraham (Sai University, India) will present on β€œGenerative AI in Healthcare”
- Nebojőa Bačanin Džakula (Singidunum University, Serbia) will talk about the latest advances in bio-inspired metaheuristics
- AIexandre Ferreira Ramos (University of SΓ£o Paulo, Brazil) will present his work on using thermodynamic models to study the regulatory logic of transcriptional control at the DNA level
- Anderson Rocha (University of Campinas, Brazil) will give a presentation entitled β€œAI in the New Era: From Basics to Trends, Opportunities, and Global Cooperation”.

And in the special AIJ Junior track, we will talk about how AI helps us learn, create and ride the wave with AI.

The day will conclude with an award ceremony for the winners of the AI Challenge for aspiring data scientists and the AIJ Contest for experienced AI specialists. The results of an open selection of AIJ Science research papers will be announced.

Ride the wave with AI into the future!

Tune in to the AI Journey webcast on November 19-21.
❀2πŸ‘Œ1
Top 50 Coding Interview Questions πŸ’»πŸš€

1. What is the time and space complexity of your code?
2. Difference between array and linked list.
3. How does a HashMap work internally?
4. What is recursion? Give an example.
5. Explain stack vs. queue.
6. What is a binary search and when to use it?
7. Difference between BFS and DFS.
8. What is dynamic programming?
9. Solve Fibonacci using memoization.
10. Explain two-pointer technique with an example.
11. What is a sliding window algorithm?
12. Detect cycle in a linked list.
13. Find the intersection of two arrays.
14. Reverse a string or linked list.
15. Check if a string is a palindrome.
16. What are the different sorting algorithms?
17. Explain quicksort vs. mergesort.
18. What is a binary search tree (BST)?
19. Inorder, Preorder, Postorder traversals.
20. Implement LRU Cache.
21. Find the longest substring without repeating characters.
22. Explain backtracking with N-Queens problem.
23. What is a trie? Where is it used?
24. Explain bit manipulation tricks.
25. Kadane’s Algorithm for maximum subarray sum.
26. What are heaps and how do they work?
27. Find kth largest element in an array.
28. How to detect cycle in a graph?
29. Topological sort of a DAG.
30. Implement a stack using queues.
31. Explain the difference between pass by value and reference.
32. What is memoization vs. tabulation?
33. Solve the knapsack problem.
34. Find duplicate numbers in an array.
35. What are function closures in Python/JavaScript?
36. How does garbage collection work in Java?
37. What are lambda functions?
38. Explain OOPs concepts: Inheritance, Polymorphism, Encapsulation, Abstraction.
39. What is multithreading vs. multiprocessing?
40. Difference between process and thread.
41. Implement a binary heap.
42. Explain prefix sum technique.
43. Design a parking lot system.
44. Find median in a stream of numbers.
45. Detect anagram strings.
46. Serialize and deserialize a binary tree.
47. Implement a trie with insert and search.
48. Explain design patterns like Singleton, Factory.
49. Discuss trade-offs between readability and performance.
50. How do you debug a tricky bug?

πŸ’¬ Tap ❀️ for detailed answers!
❀11πŸ‘1
πŸ”… Python Function
❀3
Useful Free Resources To Crack Your Next Insterview
πŸ‘‡πŸ‘‡

Job Interviewing Skills Tutorial Free Course

https://bit.ly/3RvG31E

Interview Training for Hiring Managers and Teams Free Udemy course

https://bit.ly/3fCgxe8

Coding Interview Prep Free course by Freecodecamp

https://www.freecodecamp.org/learn/coding-interview-prep/

Cracking the coding interview free book

https://t.me/crackingthecodinginterview/272

Python Interview Question and Answers for freshers

https://www.careerride.com/python-interview-questions.aspx

50 coding interview Questions book

https://www.byte-by-byte.com/wp-content/uploads/2019/01/50-Coding-Interview-Questions.pdf

Ultimate Guide to Machine Learning Interviews

https://t.me/datasciencefun/820

ENJOY LEARNING πŸ‘πŸ‘
❀1
βœ… πŸ”€ A–Z of Programming πŸ’»

A – API (Application Programming Interface)
Interface for programs to communicate with each other.

B – Bug
Error or flaw in a program that causes incorrect results.

C – Compiler
Tool that converts code into executable machine language.

D – Debugging
Process of finding and fixing bugs in code.

E – Exception
An error detected during execution, often requiring handling.

F – Function
Reusable block of code that performs a specific task.

G – Git
Version control system for tracking code changes.

H – HTML (HyperText Markup Language)
Standard language for building web pages.

I – IDE (Integrated Development Environment)
Software that combines tools for coding, testing, and debugging.

J – JavaScript
Language for building interactive web applications.

K – Keyword
Reserved word with special meaning in a programming language.

L – Loop
Structure for repeating a block of code multiple times.

M – Module
File containing reusable code, functions, or classes.

N – Namespace
Container to organize identifiers and avoid naming conflicts.

O – Object-Oriented Programming (OOP)
Paradigm based on objects and classes to structure code.

P – Parameter
Value passed to a function to customize its behavior.

Q – Query
Instruction to retrieve data, often from databases.

R – Recursion
Function that calls itself to solve a problem.

S – Syntax
Rules that define how code must be written.

T – Try-Catch
Error-handling structure to catch exceptions.

U – UI (User Interface)
Part of the program users interact with visually.

V – Variable
Named storage for data in a program.

W – While Loop
Loop that continues as long as a condition is true.

X – XML
Markup language for storing and sharing structured data.

Y – YAML
Readable format used for config files in DevOps and backends.

Z – Zero-based Indexing
Common system where counting in arrays starts at 0.

πŸ’¬ Tap ❀️ for more!
❀5
βœ… Coding Interview Questions with Answers [Part-1] πŸ’»πŸš€

1. What is the time and space complexity of your code?
Time complexity measures how the runtime grows with input size. Space complexity measures memory used. Always analyze both to optimize your solution.

2. What is the difference between an array and a linked list?
Arrays store elements contiguously with fast access by index. Linked lists store elements as nodes connected by pointers, allowing easy insertion/deletion but slower access.

3. How does a HashMap work internally?
It uses a hash function to convert keys into indexes in an array. Collisions are handled by chaining (linked lists) or open addressing.

4. What is recursion? Give an example.
Recursion is a function calling itself to solve smaller subproblems.
Example: Factorial(n) = n Γ— Factorial(n-1), with base case Factorial(0) = 1.

5. Explain stack vs. queue.
Stack: Last In First Out (LIFO), like a stack of plates.
Queue: First In First Out (FIFO), like a line at a store.

6. What is a binary search and when to use it?
Binary search efficiently finds an item in a sorted array by repeatedly dividing the search interval in half. Use on sorted data for O(log n) time.

7. What is the difference between BFS and DFS?
BFS (Breadth-First Search) explores nodes level by level using a queue.
DFS (Depth-First Search) explores as far as possible along a branch using a stack or recursion.

8. What is dynamic programming?
A method to solve problems by breaking them into overlapping subproblems and storing solutions to avoid repeated work.

9. Solve Fibonacci using memoization.
Memoization stores already calculated Fibonacci numbers in a cache to reduce repeated calculations and improve performance from exponential to linear time.

10. Explain two-pointer technique with an example.
Use two pointers to traverse data structures simultaneously.
Example: Find if a sorted array has two numbers summing to a target by moving pointers from start and end inward.

πŸ’¬ Double Tap β™₯️ For Part-2!
❀5
βœ… Coding Interview Questions with Answers [Part-2] πŸ’»πŸš€

11. What is a sliding window algorithm?
A technique for solving problems involving arrays or strings by maintaining a window that slides over data. It helps reduce time complexity by avoiding nested loops.
Example: Finding the max sum of subarrays of size k.

12. Detect cycle in a linked list.
Use Floyd's Cycle Detection Algorithm (Tortoise and Hare).
⦁ Move two pointers at different speeds.
⦁ If they meet, a cycle exists.
⦁ To find the cycle start, reset one pointer to head and move both one step until they meet again.

13. Find the intersection of two arrays.
Use a HashSet to store elements of the first array, then check each element in the second array.
⦁ Time: O(n + m)
⦁ Space: O(min(n, m))

14. Reverse a string or linked list.
⦁ For a string: Use two-pointer swap or Python's slicing.
⦁ For a linked list: Use three pointers (prev, curr, next) and iterate while reversing links.

15. Check if a string is a palindrome.
Use two pointers from start and end, compare characters.
Return false if mismatch, true if all characters match.

16. What are the different sorting algorithms?
⦁ Bubble Sort
⦁ Selection Sort
⦁ Insertion Sort
⦁ Merge Sort
⦁ Quick Sort
⦁ Heap Sort
⦁ Radix Sort
Each has different time and space complexities.

17. Explain quicksort vs. mergesort.
⦁ Quicksort: Divide and conquer, picks a pivot.
⦁ Average: O(n log n), Worst: O(n²), Space: O(log n)
⦁ Mergesort: Always divides array into halves, then merges.
⦁ Time: O(n log n), Space: O(n), Stable sort

18. What is a binary search tree (BST)?
A tree where left child < node < right child.
⦁ Efficient for searching, insertion, deletion: O(log n) if balanced.
⦁ Unbalanced BST can degrade to O(n)

19. Inorder, Preorder, Postorder traversals.
⦁ Inorder (LNR): Sorted order in BST
⦁ Preorder (NLR): Used to copy or serialize tree
⦁ Postorder (LRN): Used to delete tree

20. Implement LRU Cache.
Use a combination of HashMap + Doubly Linked List.
⦁ HashMap stores key-node pairs.
⦁ Linked list maintains access order.
⦁ When cache is full, remove the least recently used node.
Operations (get, put): O(1) time.

πŸ’¬ Double Tap β™₯️ For Part-3!
❀6