Skip to content

deepaksood619/Competitive-Programming

Repository files navigation

Competitive-Programming Repository

93 problems solved C / C++ / Java / Python 09 Oct 2017

This repostitory contains code for following-

  1. Basic Concepts -
    1. Algorithms
      1. Basic Graph Algorithms
      2. Basic Sorting Algorithms
      3. Basic Recursion Algorithms
      4. Basic Dynamic Programming Algorithms
      5. Basic Greedy Algorithms
      6. Basic Mathematics
    2. Basic Data Structures
  2. GeeksForGeeks
    1. Algorithms
  3. HackerRank
    1. Algorithms
      1. HackerRank Sorting
      2. HackerRank Strings
      3. HackerRank Graph Theory
      4. HackerRank Dynamic Programming
  4. HackerEarth
    1. HackerEarth
    2. CodeMonk
    3. HiringChallenges
  5. CodeChef
  6. LeetCode

Problems - Solutions

Basic Concepts

Basic Graph Algorithms

# Title Solution Time Space
1 Adjacency List Undirected java
2 Adjacency Matrix Directed java
3 Adjacency Matrix Undirected java
4 BFS Directed java
5 BFS Undirected java
6 Connected Components Undirected Graph java O(|V + E|) O(|V|)
7 Detect Cycle in Undirected Graph using Union and Find java O(|V * log(V)|) O(|V + E|)

Basic Sorting Algorithms

# Title Solution Time Space Notes
1 Bubble Sort java W(|N|) O(|N*N|) O(|1|) In-Place, Stable
2 Recursive Bubble Sort java W(|N|) O(|N*N|) O(|1|) In-Place, Stable
3 Counting Sort java
4 Insertion Sort java W(|N|) O(|N*N|) O(|1|) In-Place, Stable, Online
5 Recursive Insertion Sort java W(|N|) O(|N*N|) O(|1|) In-Place, Stable, Online
6 Radix Sort java
7 Selection Sort java
8 Merge Sort java O(|N*log(N)|) O(|N|) Stable
9 Merge Sort Linked List java O(|N*log(N)|) O(|N|) Stable
10 Iterative Merge Sort java O(|N*log(N)|) O(|N|) Stable
11 Quick Sort java O(|N*log(N)|) O(|1|) In-Place, Stable
12 Iterative Quick Sort java O(|N*log(N)|) O(|1|) In-Place, Stable

Basic Recursion Algorithms

# Title Solution Time Space Notes
1 Factorial java O(|N*N|) O(|1|)
2 Permutation of a given String java
3 Selection Sort Recursive java

Basic Dynamic Programming Algorithms

# Title Solution Time Space Notes
1 Fibonacci Number DP java O(|N|) O(|N|)
2 Fibonacci Number with Recursion java O(|2^N|) O(|N|)
3 Fibonacci Series with Recursion java O(|N|) O(|1|)
4 Fibonacci Series without Recursion java O(|N|) O(|1|)
5 Edit/Levenshtein Distance java O(|M*N|) O(|M*N|)
6 Min Cost Path java O(|M*N|) O(|M*N|)

Basic Greedy Algorithms

# Title Solution Time Space Notes
1 Sorted Activity Selection Problem java O(|N|) O(|1|)
2 Unsorted Activity Selection Problem java O(|N*log(N)|) O(|1|)
3 Kruskal Minimum Spanning Tree java O(|Elog(E)|) or O(|Elog(V)|) O(|V + E|)

Basic Mathematics

# Title Solution Time Space Notes
1 Prime Factors c++ O(|log(N)|) O(|1|)
2 Sieve of Eratosthenes c++ O(|N*log(log(N))|) O(|N|)

Basic Data Structures

# Title Solution Time Space Notes
1 Disjoint Set java O(|log(N)|) O(|N|) Using Path Compression and Union by Rank

Geeks For Geeks Algorithms

# Problem Solution Time Space
1 Largest Even Number java
2 Palindrome String java
3 Sum Of Digit Is Palindrome Or Not java
4 X Total Shapes java
5 Floyd Tortoise and Hare java O(|N|)
6 Sort The Array java O(|N*log(N)|)
7 N Meetings in One Room java O(|N*log(N)|)
8 Detect Cycle in Directed Graph java O(|V + E|)
9 Edit Distance java O(|M*N|)
10 Highest Prime c++
11 Largest Prime Factor c++
12 Path in Matrix java
13 Least Prime Factor C++
14 Check for Subsequence C++

HackerRank

HackerRank Sorting

# Problem Solution Time Space Difficulty Points
1 Big Sorting java Easy 20
2 Insertion Sort 1 java O(|N*N|) O(|1|) Easy 30
3 Insertion Sort 2 java O(|N*N|) O(|1|) Easy 30

HackerRank Strings

# Problem Solution Time Space Difficulty Points
1 Beautiful Binary String java Easy 20
2 Gemstones java Easy 20
3 Making Anagrams java Easy 30
4 Mars Exploration java Easy 15
5 The Love Letter Mystery java Easy 20
6 Game of Thrones 1 java O(|N|) O(|1|) Easy 30
7 Anagram java O(|N|) O(|1|) Easy 25
8 Two Strings java O(|N|) O(|1|) Easy 25

HackerRank Graph Theory

# Problem Solution Time Space Difficulty Points
1 Roads and Libraries java O(|V|) O(|V|) Medium 30
2 Journey to the Moon java O(|V + E|) O(|V|) Medium 50

HackerRank Dynamic Programming

# Problem Solution Time Space Difficulty Points
1 Fibonacci Modified java O(|N|) O(|1|) Medium 45
2 The Coin Change Problem java O(|total*coins|) O(|total|) Hard 60

HackerEarth

# Problem Solution Time Space Points Notes
1 Alex And Priority Queues java
2 Alex And Requests java
3 Disconnected Graph java
4 Sum of Subsets java
5 RhezoAndBigPowers java 30 Used BigInteger build in modPow() function
6 Roy And Trains java 20
6 Roy And Wobbly Numbers java 20
7 Sherlock And Dates java 20
8 The Best Player java 20
9 Crazy Matrix java 30
10 Crushing Violence java 20
10 Fizz Buzz java C++ 20

HackerEarth CodeMonk

  1. Basics of Input Output
  2. BitManipulation

HackerEarth Hiring Challenges

# Problem Solution Time Space Points Notes
1 Find The String java / python
2 Fredo and Two Strings cpp / java

Follow my progress -

  1. Hacker Rank
  2. Geeks for Geeks
  3. Hacker Earth
  4. Code Chef
  5. Leet Code
  6. Linkedin

Love