https://github.com/naemazam/data-structures-and-algorithms-gfg
Data Structures and Algorithms problem and solution from GeekforGeeks with CP Books and Notes
https://github.com/naemazam/data-structures-and-algorithms-gfg
coding-challenge coding-interviews cpp geekforgeeks geekforgeeks-solutions interview-practice interview-preparation interview-preparation-kit interview-questions naemazam problem-solving python
Last synced: 3 months ago
JSON representation
Data Structures and Algorithms problem and solution from GeekforGeeks with CP Books and Notes
- Host: GitHub
- URL: https://github.com/naemazam/data-structures-and-algorithms-gfg
- Owner: naemazam
- License: bsd-3-clause
- Created: 2023-08-01T04:16:52.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-01T04:38:12.000Z (about 2 years ago)
- Last Synced: 2025-03-04T10:14:42.511Z (7 months ago)
- Topics: coding-challenge, coding-interviews, cpp, geekforgeeks, geekforgeeks-solutions, interview-practice, interview-preparation, interview-preparation-kit, interview-questions, naemazam, problem-solving, python
- Language: C++
- Homepage:
- Size: 8.58 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Data-Structures-and-Algorithms-GFG
Data Structures and Algorithms problem and solution from GeekforGeeks with CP Books and Notes# Interview Data-Structures-and-Algorithms-GFG Problems from GeekforGeeks
This repository is a collection of my solutions to the must do probelms in [geeksforgeeks](https://www.geeksforgeeks.org/must-do-Data-Structures-and-Algorithms-GFG-questions-for-companies-like-amazon-microsoft-adobe/)
## 0. To get started follow the Books
1. [The Data-Structures-and-Algorithms-GFG Book](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Data-Structures-and-Algorithms-GFGBook.pdf)
2. [Cracking-the-Data-Structures-and-Algorithms-GFG-Interview-6th-Edition-189-Programming-Questions-and-Solutions](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Cracking-the-Data-Structures-and-Algorithms-GFG-Interview-6th-Edition-189-Programming-Questions-and-Solutions.pdf)
3. [Guide to Competitive Programming_ Learning and Improving Algorithms Through Contests](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Guide%20to%20Competitive%20Programming_%20Learning%20and%20Improving%20Algorithms%20Through%20Contests%20(%20PDFDrive.com%20).pdf)
## 1. Divide and Conquer0. [Find the element that appears once in sorted array](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Divide%20and%20Conquer/0_Find_Elements.cpp)
1. [Search in a Rotated Array](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Divide%20and%20Conquer/1_Search.cpp)
2. [Binaray Search](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Divide%20and%20Conquer/2_Binary_Search.cpp)
3. [Sum of Middle Elements of two sorted arrays](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Divide%20and%20Conquer/3_Merge.cpp)
4. [Quick Sort](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Divide%20and%20Conquer/4_Quick_Sort.cpp)5. [Merge Sort](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Divide%20and%20Conquer/5_Merge_Sort.cpp)
6. [K-th element of two sorted Arrays](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Divide%20and%20Conquer/6_K-th_Element.cpp)## 2. Recursion
0. [Flood fill Algorithm](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Recursion/0_Flood_Fill.cpp)
1. [Number of paths](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Recursion/1_Num_of_Paths.cpp)
2. [Combination Sum – Part 2](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Recursion/2_CombnSum.cpp)
3. [Special Keyboard](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Recursion/3_Special_keyboard.cpp)
4. [Josephus problem](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Recursion/4_Josephus_Problem.cpp)
## 3. Arrays0. [Subarray with given sum](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/0_Rotate_Array.cpp)
1. [Count the triplets](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/1_Subarray_Sum.cpp)
2. [Kadane’s Algorithm](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/2_Counting_Triplets.cpp)
3. [Missing number in array](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/3_Kadane_Algorithm.cpp)
4. [Merge two sorted arrays](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/4_Merge_Spaceless.cpp)
5. [Rearrange array alternatively](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/5_Rearrange_Array_Alt.cpp)
6. [Number of pairs](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/6_Num_Pairs.cpp)
7. [Inversion of Array](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/7_Inversion.cpp)
8. [Sort an array of 0s, 1s and 2s](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/8_Sort_0s_1s_2s.cpp)
9. [Equilibrium point](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/9_Equillibrium_Point.cpp)
10. [Leaders in an array](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/10_Leaders.cpp)
11. [Minimum Platforms](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/dab51bc33a6837db0a7052d5560b547d90cc6134/Arrays/11_Min_Platforms.cpp)
12. [Reverse array in groups](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/12_Rev_Ar_Grps.py).
13. [K’th smallest element](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/13_kth_smallest_element.cpp)
14. [Trapping Rain Water](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/14_Trapping_Rain.py)
15. [Pythagorean Triplet](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/15_Pythogorean_Triplet.py)
16. [Chocolate Distribution Problem](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/16_Choclate_dist.py)
17. [Stock buy and sell](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/17_Stock_Buy_Sell.py)
18. [Element with left side smaller and right side greater](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/18_Middle.py)
19. [Convert array into Zig-Zag fashion](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/19_ZigZag.py)20. [Last Index of 1](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/20_Last_index_1.py)
21. [Spirally traversing a matrix](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/21_Spiral_Traversal.cpp)
22. [Largest Number formed from an Array](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Arrays/22_Largest_Num.cpp)## 4. Strings
0. [Reverse words in a given string](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Strings/0_Reverse_Words.py)
1. [Permutations of a given string](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Strings/1_Permutations.py)
2. [Longest Palindrome in a String](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Strings/2_Longest_Palindrome.py)
3. [Recursively remove all adjacent duplicates](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Strings/3_Remove_Adj_dups.py)
4. [Check if string is rotated by two places](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Strings/4_Check_String_Rot.py)
5. [Roman Number to Integer](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Strings/5_Roman_to_Int.py)
6. [Anagram](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Strings/6_Anagram.py)7. [Remove Duplicates](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Strings/7_Rm_Dups.py)
8. [Form a Palindrome](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Strings/8_Form_Palindrome.py)
9. [Longest Distinct Characters in the string](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Strings/9_Distinct_Chars.py)
10. [Implement Atoi](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Strings/10_AtoI.py)
11. [Implement strstr](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Strings/11_StrStr.py)
12. [Longest Common Prefix](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Strings/12_LongCommPrefix.py)
## 5. Linked List
0. [Finding middle element in a linked list](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/0_Find_the_Middle.cpp)
1. [Reverse a linked list](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/1_Reverse.cpp)
2. [Rotate a Linked List](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/2_Rotate.cpp)
3. [Reverse a Linked List in groups of given size](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/3_Reverse_with_k.cpp)
4. [Intersection point in Y shaped linked lists](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/4_Find_The_Y_intersection.cpp)
5. [Detect Loop in linked list](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/5_Detect_Loop.cpp)
6. [Remove loop in Linked List](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/6_Remove_Loop.cpp)
7. [N’th node from end of linked list](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/7_Nth_Node_from_End.cpp)
8. [Flattening a Linked List](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/8_Flattening_List.cpp)
9. [Merge two sorted linked lists](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/9_Merge.cpp)
10. [Intersection point of two Linked Lists](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/10_Pairwise_Swap.cpp)
11. [Pairwise swap of a linked list](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/11_Add_two_ll_num.cpp)
12. [Add two numbers represented by linked lists CPP](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/12_Check_Palindrome.cpp) , [Add two numbers represented by linked lists Java](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/18_Add_two_num.java)
13. [Check if Linked List is Palindrome](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/13_Queue.cpp)
14. [Implement Queue using Linked List](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/14_Stack.cpp)
15. [Implement Stack using Linked List](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/15_Sort_0s1s2s.cpp)
16. [Given a linked list of 0s, 1s and 2s, sort it](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/16_Delete_without_head.cpp)
17. [Delete without head pointer](https://github.com/naemazam/Data-Structures-and-Algorithms-GFG/blob/master/Linked%20Lists/17_Delete_headless.cpp)## 6. Stack and Queue
## 7. Tree and BST