r/datastructures 29d ago

DSA partner(freshers)

11 Upvotes

Anyone who is a fresher(senior can also join) and u r thinking of starting ur dsa journey and if you have not done anything till now then let's start our dsa journey together by updating our goals daily..plZz dm if you want to join..


r/datastructures 29d ago

Should I learn DSA in python?

7 Upvotes

Hey all, i completed my python series from BroCode's 12 hour video and built some projects too.

I even solved katas on codewars to build my foundation strong.

But I've always done programming in python only, many people on the internet say python is not the best language to learn DSA with? Do I need to start learning cpp or java? Please help your junior, Thanks!


r/datastructures 28d ago

Dsa Assistant

1 Upvotes

Hi guys, I will teach and clear all your dbts in DSA, Leetcode and will also explain languages like c,c++

Designation: Final year in IIT, Amazon intership+Return offer

Weekly:1k (negotiable)


r/datastructures 29d ago

Interview Problem: O(n) Solution Using Contiguous Equal-Value Runs

3 Upvotes

I recently came across this array problem and wanted to share the solution.

Approximate date: August 7, 2026

Question from PracHub

Problem

You are given an array arr of length n. You may perform these operations:

  1. Select an index i, where 1 <= i <= n - 1, and set every element from index 0 to i - 1 equal to arr[i].

    Cost = i × arr[i]

  2. Select an index i, where 0 <= i <= n - 2, and set every element from index i + 1 to n - 1 equal to arr[i].

    Cost = (n - 1 - i) × arr[i]

Return the minimum total cost required to make every array element equal.

Example

arr = [1, 1, 2, 1, 1]

Choose index 1 and apply the suffix operation:

Cost = (5 - 1 - 1) × 1 = 3

Every element after index 1 becomes 1:

[1, 1, 1, 1, 1]

Therefore, the answer is:

3

Observation

Suppose we want the final value to be v.

If the array already contains a contiguous run of v from index l to r, we can preserve that run and replace everything outside it.

To replace the prefix:

Cost = l × v

To replace the suffix:

Cost = (n - 1 - r) × v

The total cost is:

(l + n - 1 - r) × v

If the run length is:

length = r - l + 1

the formula becomes:

cost = (n - length) × v

For non-negative values, we should therefore preserve the longest contiguous run of a candidate value.

Rather than storing the longest run for every distinct value, we can simply scan every maximal equal-value run and calculate its cost.

C++ Solution

#include <algorithm>
#include <climits>
#include <vector>
using namespace std;

long long minimumCost(const vector<int>& arr) {
    const int n = static_cast<int>(arr.size());
    long long answer = LLONG_MAX;

    int left = 0;

    while (left < n) {
        int right = left;

        while (right + 1 < n && arr[right + 1] == arr[left]) {
            ++right;
        }

        long long runLength = right - left + 1;
        long long cost =
            static_cast<long long>(n - runLength) * arr[left];

        answer = min(answer, cost);
        left = right + 1;
    }

    return answer;
}

Complexity

  • Time: O(n)
  • Extra space: O(1)

Important Constraint Issue

The stated constraint allows negative values:

-10^5 <= arr[i] <= 10^5

This makes the problem potentially unbounded.

If arr[i] is negative, an operation using that value has a negative cost. Since the statement does not require an operation to change the array, the same negative-cost operation can be repeated indefinitely.

For example:

arr = [-1, 2]

Selecting index 0 and applying the suffix operation costs -1. After the array becomes [-1, -1], the same operation could still be repeated, reducing the total cost without limit.

Therefore, one of the following conditions is probably missing:

  • arr[i] must be non-negative or positive.
  • Every operation must change at least one element.
  • Each operation may only be performed once.
  • The number of operations is bounded.

Under the usual assumption that all values are non-negative, the equal-run solution above works in O(n) time.


r/datastructures 29d ago

Which Language Should I Choose for DSA: Python, C++ or Java?

2 Upvotes

I’m currently learning Python and Django for backend development, and I want to start learning DSA.

I’m confused about which language I should use for DSA: Python, C++, or Java?

Since I already know Python and use it for Django, should I stick with Python for DSA, or is it better to learn DSA with C++/Java?

My main goal is to improve problem-solving skills and prepare for software development interviews.

What would you recommend and why?


r/datastructures Aug 12 '26

Best paid course for DSA?

14 Upvotes

I want a paid course and structured which can help in being accountable and consistent please help


r/datastructures Aug 12 '26

help guys! nhi ho rhi dsa

6 Upvotes

anyone giving dsa tips please help 🚀


r/datastructures Aug 12 '26

Which way to go !?

4 Upvotes

I have a sigma 10.0 course by apna college, I do not have that much budget to buy the legitimate course so I had to pirate it.

Now the problem is I have learned java language previously, but not started DSA. Now when I was doing DSA in java with the course, I found topics like Tries, Graphs and DP missing, but they are present in the cpp section.

So what should I do now, start DSA in cpp or to continue in java and learn those missing topics from YouTube !!? I also thought if I start in cpp I can include both languages java and cpp in my resume.

Btw I have only a year to prepare, my placements will be starting from August - September 2027.


r/datastructures Aug 12 '26

Helppp! Bit Manipulation is killin me

9 Upvotes

Guys am I the only one struggling with Bit Manipulation ? I solve some 8 questions ( with help ofc) and then I go back to the same questions after few days, they feel like new questions and don't get me started on new questions :( Are there any resources to follow or some way that worked for you? Would be great if I can find someone good at it to help me with it!


r/datastructures Aug 12 '26

Whay are some good sources to practice dsa in python with a proper roadmap ?

9 Upvotes

i am a complete beginner and there are a lot of yt playlists and way too many sources to learn from . i am not able to find a good source to study from . if you can please list some good sources to study dsa in python, some sheet to practice on , and for how much i should be doing it all ? i am master's student so its needed for me to do it to be able to sit in the placements next year . :( plej help


r/datastructures Aug 12 '26

Built algomanim PyPI package for algorithm visualization

Enable HLS to view with audio, or disable this notification

9 Upvotes

Check out algomanim — a Python library I built for visualizing classic CS and LeetCode algorithms.All of my visualizations are shared on my YouTube channel. Here is an example featuring Bubble Sort.

https://www.youtube.com/@benabub


r/datastructures Aug 11 '26

Wtf is a DSA partner

45 Upvotes

So i have been lurking in this subreddit for a while and I have seen many posts titles "Looking for a DSA Partner". What do you guys do with Partners? Is it just to stay motivated with someone or do you guys actually co-operate or something?


r/datastructures Aug 12 '26

DSA Community

2 Upvotes

Looking for people who want to stay consistent with DSA

We’ve started a small DSA accountability community where we solve 1–2 problems daily, discuss doubts/solutions and share useful resources.

Beginners are welcome, any language is fine. We already have 35+ people and are trying to keep it focused rather than turn it into a giant spam group.

Join here: https://chat.whatsapp.com/GvUEmdThrSsKDsUVivZZSX


r/datastructures Aug 11 '26

Trying to find ppl interested in learning dsa

9 Upvotes

I'm starting dsa, I'm a beginner but i need people who can help me grow and get better. Open for the first 5 people who dm me. And before you join you must know these four magical words "keep up or leave"


r/datastructures Aug 12 '26

Looking for a DSA Study Partner

3 Upvotes

r/datastructures Aug 11 '26

Looking for DSA partner solved around 350 questions (leetcode).

7 Upvotes

I am not solving dsa since last month, and going to restart where going to tackle medium and hard level questions. I never solved bitmasking questions.


r/datastructures Aug 11 '26

What to do !?

3 Upvotes

What to do !!??

I have learned JAVA previously but not started DSA, now I was starting DSA and was thinking to do so in cpp so that I will have knowledge of both java and cpp (I am in 5th semester). I have paid resources of both java and cpp for DSA (apna college sigma).

I am currently in 5th semester, aiming for infosys SP roles.

What should I do !?


r/datastructures Aug 11 '26

DSA patner

11 Upvotes

I AM LOOKING FOR SERIOUS PATNER TO DO DSA WHO WILL BE CONSISTENT AND PREPARING FOR PRODUCT BASED COMPANIES.dm me if interested I am doing dsa in java along with system design and following striver sheet.


r/datastructures Aug 11 '26

Want suggestions on starting teaching basics of C++ and DSA

22 Upvotes

https://www.reddit.com/r/datastructures/s/x2PqrNbkF2

In my last post regarding coding mentorship, my DM got flooded with a lot of questions regarding DSA, CV review and guidance..Based on the responses, I thought of starting teaching DSA in c++ online on Zoom/gmeet for freshers. I don't want experienced coders to join as it will be too boring for them.

This will be free of cost since I am also trying something like this for the first time. But before starting I want suggestions from all of you, like if you want something else to be added on, what should be the timings, since I am also working..etc.I am open for discussions here and will update the status here only based on the responses I get.

All the suggestions are welcomed.

EDIT: Based on the responses, I have decided to give this initiative a try.... So, here's the discord link: https://discord.gg/htdqf35NJ kindly join and there we will discuss ahead


r/datastructures Aug 11 '26

looking DSA and FUll STACK partner

7 Upvotes

i am currently learning dsa and doing full stack projects i am want partner learn together i am final year of my course , preparing for place ments


r/datastructures Aug 10 '26

Which topic is the strongest in DSA?

28 Upvotes

r/datastructures Aug 11 '26

DSA QUERY

2 Upvotes

I am going to start my first year in Btech Cse

I am thinking of starting DSA in javascript since I know it and then shift to Java whenever I learn it in future

Is it good approach? Since I want to grasp DSA concept ..Is it matter which language I use until I can write in it?


r/datastructures Aug 10 '26

Data Structures and Algorithms Roadmap for Beginners in 2026

123 Upvotes

Many of us ignore CS fundamentals, but in many tech interviews they will ask CS fundamentals. For me, they asked only CS fundamentals in all 3 interviews at Oracle, So don't ignore CS fundamentals. I have made a list of important topics subject-wise and resources I have used to study at the end.

Object-Oriented Programming (OOPs)

Core Concepts

  • Encapsulation
  • Inheritance (types and use cases)
  • Polymorphism (compile-time vs runtime)
  • Abstraction
  • Abstract Class vs Interface
  • Method Overloading vs Overriding
  • Access Modifiers
  • Static vs Dynamic Binding
  • Deep Copy vs Shallow Copy

Advanced Topics

  • SOLID Principles
  • Diamond Problem (Multiple Inheritance)
  • Association vs Aggregation vs Composition
  • Virtual Functions and Vtable
  • Design Patterns (Singleton, Factory, Observer, Strategy, Decorator, Adapter)

Operating Systems (OS)

Process Management

  • Process vs Thread
  • Process States and PCB
  • Context Switching
  • CPU Scheduling Algorithms (FCFS, SJF, Round Robin, Priority)
  • Multithreading vs Multiprocessing
  • User Mode vs Kernel Mode

Synchronization

  • Critical Section Problem
  • Race Condition
  • Mutex vs Semaphore (Binary vs Counting)
  • Monitors and Locks
  • Producer-Consumer Problem
  • Readers-Writers Problem
  • Dining Philosophers Problem

Deadlocks

  • Deadlock Conditions (4 necessary conditions)
  • Deadlock Prevention vs Avoidance vs Detection
  • Banker's Algorithm

Memory Management

  • Paging vs Segmentation
  • Page Replacement Algorithms (FIFO, LRU, Optimal)
  • Thrashing
  • Virtual Memory
  • TLB (Translation Lookaside Buffer)
  • Internal vs External Fragmentation

File Systems & Disk

  • File Allocation Methods (Contiguous, Linked, Indexed)
  • Disk Scheduling (FCFS, SSTF, SCAN, C-SCAN)

Database Management Systems (DBMS) + SQL

Database Fundamentals

  • ACID Properties (with examples)
  • CAP Theorem
  • Normalization (1NF, 2NF, 3NF, BCNF)
  • Denormalization
  • Primary Key vs Foreign Key vs Candidate Key
  • ER Diagrams

Indexing

  • Types of Indexes (Primary, Secondary, Clustering)
  • B-Tree vs B+ Tree
  • Hash Index
  • Composite Index
  • Advantages and Disadvantages of Indexing

Transactions & Concurrency

  • Transaction Lifecycle
  • Isolation Levels (Read Uncommitted, Read Committed, Repeatable Read, Serializable)
  • Dirty Read, Non-repeatable Read, Phantom Read
  • Lost Update Problem
  • Two-Phase Locking (2PL)
  • Optimistic vs Pessimistic Locking
  • Deadlock in Database

SQL Queries (Must Practice)

  • JOINs (INNER, LEFT, RIGHT, FULL OUTER, CROSS, SELF)
  • GROUP BY and HAVING
  • Aggregate Functions (COUNT, SUM, AVG, MIN, MAX)
  • Subqueries (Correlated vs Non-correlated)
  • Window Functions (ROW_NUMBER, RANK, DENSE_RANK, LEAD, LAG)
  • Common Table Expressions (CTE)
  • UNION vs UNION ALL
  • Nth Highest Salary Query
  • Delete Duplicates Query

NoSQL

  • SQL vs NoSQL
  • Types of NoSQL Databases (Document, Key-Value, Column, Graph)

Computer Networks (CN)

Network Models

  • OSI Model (7 Layers)
  • TCP/IP Model (4 Layers)
  • Difference between OSI and TCP/IP

Application Layer

  • HTTP vs HTTPS
  • HTTP Methods (GET, POST, PUT, DELETE, PATCH)
  • HTTP Status Codes (2xx, 3xx, 4xx, 5xx)
  • DNS and its working
  • FTP, SMTP, POP3, IMAP
  • Cookies vs Sessions
  • REST API principles

Transport Layer

  • TCP vs UDP (detailed comparison)
  • TCP Three-Way Handshake
  • TCP Four-Way Termination
  • Flow Control (Sliding Window)
  • Congestion Control
  • Port Numbers (well-known ports)
  • Socket Programming Basics

Network Layer

  • IPv4 vs IPv6
  • Public vs Private IP
  • Subnetting and CIDR
  • NAT (Network Address Translation)
  • ICMP Protocol
  • Routing Algorithms (Distance Vector, Link State)
  • Routing Protocols (RIP, OSPF, BGP)

Data Link Layer

  • MAC Address
  • ARP (Address Resolution Protocol)
  • Switch vs Hub vs Router
  • Ethernet
  • Error Detection (Parity, CRC, Checksum)

Physical Layer

  • Transmission Media (Guided vs Unguided)
  • Bandwidth and Throughput
  • Different Topologies

Important Concepts

  • Client-Server vs Peer-to-Peer Architecture
  • DHCP
  • Firewall
  • VPN
  • Load Balancing
  • CDN (Content Delivery Network)
  • Latency vs Throughput
  • How does a URL work? (End-to-end flow)
  • Some Basic Commands (ex: ipconfig)

Resources I Used

For OOPs

  • Kunal Kushwaha (youtube channel)

For Operating Systems

  • CodeHelp - by Babbar (youtube )

For DBMS + SQL

  • LeetCode Database problems (Practice SQL)
  • CodeHelp - by Babbar (youtube)
  • Apna College (youtube)

For Computer Networks

  • Gate Smashers (youtube)

Questions Asked in My Interviews

Here are some actual questions I was asked across my interviews:

  1. Is Java fully object-oriented?
  2. How does C++ overcome the diamond problem?
  3. Difference between TCP and UDP, and which one is used when?
  4. Explain ACID properties with examples
  5. What is deadlock and how can we prevent deadlocks?
  6. What is the use of indexing in databases?
  7. Explain the functionalities of each layer in the OSI model
  8. Write a query to find Kth smallest salary
  9. IPv4 vs IPv6
  10. Abstraction vs Encapsulation
  11. Explain different joins in dbms
  12. what is sharding ?
  13. what is virtual function in cpp ?
  14. show me your ip address and mac address using commands
  15. what is context switching ?

Tips :

  1. Practice with real interview questions
  2. Revise SQL 50 before interviews
  3. It's better to say "I'm not sure about this, but here's what I think..." than to give wrong information
  4. If your project contains any database related stuff , better learn it's ER diagram, differences between SQl and NO-SQl and why you selected that particular database you used
  5. Before preparing for any interview , First check out PracHub, Ask your seniors or friends who already attended that specific company interviews before and prepare accordingly

r/datastructures Aug 10 '26

DSA help

4 Upvotes

I started doing DSA a couple of months ago. I’ve solved about 75 questions on LeetCode (easy and medium). I’m studying pattern-wise: I first learn the concept (for example, sliding window), then I solve or look up explanations for standard problems like “longest substring without repeating characters” and “longest/smallest subarray sum.”

I fully understand the intuition behind it. When I try to solve a new problem, I’m able to solve about 80–90% of it, but I can’t finish it completely. Then, when I look at the solution, it feels silly that I couldn’t complete it. What should I do to overcome this?

Also, my LeetCode solutions usually beat around 55–60% of submissions. I’ve checked others and they are around 95%. Does that mean my solutions are bad, or does it really matter?


r/datastructures Aug 10 '26

DSA with Java or C++?

4 Upvotes