0% found this document useful (0 votes)
267 views

Introduction To CP and DSA

This document provides an overview of data structures and algorithms (DSA) and competitive programming. It defines data structures as a way to store and organize data to be used efficiently by algorithms, which are solutions to problems. Different approaches to solving a sample problem of finding a missing number in a sorted array are presented. The importance of learning DSA for interviews is discussed. Resources for learning DSA like websites, courses, and practice problems are listed. Tips for competitive programming like choosing a language and writing test cases are provided. The document distinguishes competitive programming and DSA from software development and suggests allocating time to both.

Uploaded by

Maitray Wani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
267 views

Introduction To CP and DSA

This document provides an overview of data structures and algorithms (DSA) and competitive programming. It defines data structures as a way to store and organize data to be used efficiently by algorithms, which are solutions to problems. Different approaches to solving a sample problem of finding a missing number in a sorted array are presented. The importance of learning DSA for interviews is discussed. Resources for learning DSA like websites, courses, and practice problems are listed. Tips for competitive programming like choosing a language and writing test cases are provided. The document distinguishes competitive programming and DSA from software development and suggests allocating time to both.

Uploaded by

Maitray Wani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

we will start shortly...

Data Structure & Algorithm


(DSA)
Data Structure & Algorithms
● Data Structures are a programmatic
way of storing data so that data can be
used efficiently.
● An algorithm is nothing but a
description of steps to solve a problem.
In simple words, it’s a solution to a
problem.
● Data structures are used to hold data
while algorithms are used to solve the
problem using that data.
Simple Example
Given an array of size N,
Which contains numbers from 1 to N+1.
Therefore, one number is missing. Find the
missing number.
[ 1, 5, 4, 2, 7, 6 ] N=6
Output: 3
Approach 1:
For each number from 1 to N+1, loop through the
array and check if it is present or not. If not then
that’s the answer(missing number).
(Bruteforce)
Simple Example
Given an array of size N,
Which contains numbers from 1 to N+1.
Therefore, one number is missing. Find the
missing number.
[ 1, 5, 4, 2, 7, 6 ] N=6
Output: 3
Approach 2:
Sort the array.
[ 1, 2, 4, 5, 6, 7 ]
Loop and check which number is not present
sequentially.
(A little better than before)
Simple Example
Given an array of size N,
Which contains numbers from 1 to N+1.
Therefore, one number is missing. Find the
missing number.
[ 1, 5, 4, 2, 7, 6 ] N=6
Output: 3
Approach 3:
Sum of first N natural numbers = N(N+1)/2
Consider N = 7, 7*8/2 = 28
Total Array Sum = 1+5+4+2+7+6 = 25.
Answer = 28 - 25 = 3
(Very efficient)
Why Should One Learn DSA
Why Should One Learn DSA

● Data structures and


algorithms (DSA) goes
through solutions to
standard problems in detail
and gives you an insight into
how efficient it is to use each
one of them
● Major part of Interviews is
based on DSA
Learning Resources for DSA

● GFG : Has a Whole Archive for DSA


● Online Courses/YT Playlist :
○ Abdul Bhari
○ Apna College
● DSA Sheet :
○ Striver’s List : Video
○ Love Babbar’s 450 List : Video
Practice! Practice!! Practice!!!
Practice DSA

● Few Websites where you can practice


DSA
○ CSES Problem Set - Tasks
○ LeetCode
○ GFG Practice
○ InterviewBit

● Roadmap for DSA


○ Roadmap by Striver
Competitive Programming
What is CP ?

Competitive programming is a mind sport


usually held over the Internet involving
participants all around the global trying to
program according to provided
specifications aka “Coding Problem”

Ex : Codeforce's Contests
Platforms for CP
1. Codeforces
2. Codechef
3. Atcoder
4. Topcoder
5. https://clist.by/
Major Competition Held by
Institution & Firms
1. KickStart By Google
2. HackerCup By Facebook
3. ACM ICPC
Which language to use?
Why CP?

1. Improves Logic & Speeds up coding


2. Helps you develop Good problem
solving Skills
3. Helps you crack hiring Companies
coding rounds
How to do CP properly ?

● Prepare for the contest


● Participate in the contest
● Check the editorial after the contest
● Practice/Learn the Concepts which are
new to you or need in practice it
● And Repeat
Resources
(for learning)
1. DSA
2. CP handbook
3. CP Algorithms
4. Combined resources by a senior
5. GeeksForGeeks
6. Youtubers:
a. Striver
b. Second Thread
c. Errichto
Resources
(for practice)
1. Codeforces
2. Codechef
3. Atcoder
4. Topcoder
5. Cses
6. Leetcode
7. geeksforgeeks
8. Code signal
9. Hackerrank
10. Hackearth
Development
VS
Competitive
Programing & DSA
Development VS Competitive
Programing & DSA
Development VS Competitive
Programing & DSA
● DSA & Development is MUST
● Competitive Programming is Optional
● So Why Competitive Programming ?
How much Time should one
devote ??
How much Time should one
devote ??
● Totally Depends on you
● One Can manage doing both
Development and Competitive
Programming at the same time
● Just Participate in the contest and do
remember to check the editorial after
the round
Competitive Programming
Tips/Guide
● Do Chase Behind the Rating but don’t
cheat during the contest.
● Select a programming language which
you are most comfortable and stick
with it.
● Write test cases for the problem and
test your logic using those test cases
before submitting.
Competitive Programming
Tips/Guide
● Also try sticking to
the website you
have chosen for
practice.
● Also CP wale
solution Interview
Round mein mat
dena
Just koi Random CP MEME , Waise
PPT Khatam, koi Doubt he ?

You might also like