Geeks-for-geeks-solutions
In this repository you will find:
- Generic Practicse coding challenges solutions
- Amazon SDE preparation solutions
- Solution of the must Do coding questions for Amazon, Microsoft, Adobe
- Solution of the 11 weeks ADS GeeksForGeeks workshop
Get mentored by me
Technologies
Author
- Davide Pollicino GeeksForGeeks profile. If you need more material like this, nominate me as github start, to get help the project to gain more visibility and contributions
Index of content
Algorithms and Data structures
- Programming foundamental
- Array
- Vectors
- Sorting
- String
- Matrix
- Linked List
- Stack
- Queue
- Set and Multiset
- Map
- Heap
- Search
- Tree and BST
- Graph
- Math and Bit Magic
- Prime Numbers
- Recursion
Programming foundamentals
Name | Solution |
---|---|
Replace all 0' with 5 | Python |
Strongesth neighbour | C++ |
Data types in Java | Java |
Larghest element in array | Python |
Start coding | Java |
Split strings | C++ |
Sum of digits | C++ |
Odd or even | C++ |
Palindrome | C++ |
Mean | C++ |
Check the status - Python | Python |
If conditional statement- Python | Python |
Count of camel case characters | C++ |
Sum of matrix elements | C++ |
Addition of two numbers | C++ |
The new line | Java |
Java Inheritance | Java |
Even-odd in Java | Java |
Hello Word-python | Python |
Comparison | Python |
Functions - Python | Python |
Split the input | Python |
Taking input | Python |
Is and in operator | Python |
For loop python | Python |
While loop in python | Python |
Repeatitive printing-python | Python |
Sep and End | Python |
Logical operators | Python |
Sep -Space separate | Python |
Comment in python | Python |
Cat and hatPython | |
For loop2 (index jumper) | Python |
Operators in python | Python |
JUmping through while | Python |
Step-by-step-condition | C++ |
Learn to Comment | C++ |
Print from 1 to N using recursion | C++ |
Swap the objects | C++ |
Array update by index | C++ |
While Loop print table | C++ |
New line | C++ |
Prime check | C++ |
Get array element at index | C++ |
Count smaller than x | C++ |
Count bigger than x | C++ |
Count immediate bigger | C++ |
Sum of array elements | C++ |
Taking input | C++ |
Logical operators | C++ |
Bitwise operator | C++ |
Even odd | C++ |
data tpes | C++ |
Find the fine | C++ |
Reverse vowels - improved | C++ |
Value equal to index value | C++ |
Greates of 3 numbers | C++ |
Full prime | C++ |
Array or Vector
Name | Solution in C++ | Python |
---|---|---|
Find index | c++ | |
Bitonic Point | Python | |
Sum of Middle Elements of two sorted arrays | Python | |
Sum of array | C++ | |
Print the left element | Python | |
Frequency of array elements | C++ | |
Multiplication table | C++ | |
Product of maximum in first array and minimum in second | C++ | |
At least two greater element | C++ | |
C++ Array (print an element) | Set 2 | C++ |
Sub array with given sum (print index range of the subarray) | C++ | |
SUm of array elements-2 | C++ | |
C++ Arrays (Sum of array) | Set 1 | C++ |
Count 1s in sorted array | C++ | |
Search in sorted array | C++ | |
Insert at end of array | C++ | |
Equilibrium point | C++ | |
Left index | C++ | |
Check if an array is sorted | C++ | |
Print alternate elements of an array | C++ | |
Number of occurrency | C++ | |
C++ | ||
Median of two arrays | C++ | |
Missing number in an array | C++ | |
Sort array of 0s, 1s and 2 | C++ | |
Product of array element | C++ | |
Index of first 1 in sorted boolean array | C++ | |
Find number of numbers | C++ | |
Sum of distinct element | C++ | |
Multiply left and right array sum | C++ | |
Greater on right side | C++ | |
Minimum product pair | C++ | |
Find unique element | C++ | |
Count only repeated elements | C++ | |
Remove duplicate elements | C++ | |
Search element in array | C++ | |
Check if two arrays are equals | C++ | |
Generate Permutation(single case example) | C++ | |
Min and max element | C++ | |
Is array sorted | C++ | |
Balanced array | C++ | |
Find Index | C++ | |
Array delete and shift | C++ | |
Array insert at index | C++ | |
Merge two sorted arrays O(1) space | C++ | |
Union of two sorted array | C++ | |
Index of an extra element | C++ | |
Binary array sorting | C++ | |
Find transition point | C++ | |
Mean and median of an array | C++ | |
Rotate array by n elements | C++ | |
Find min and maximum number | C++ | |
Count Evens and odds | C++ | |
Leaders in array | C++ | |
Who has the majority element | C++ | |
Sort array os 0s, 1 and 2s | C++ | |
Reverse the array | C++ | |
Reverse array - High modularity | C++ | |
Need some change | C++ | |
Find the frequency | C++ | |
Immediate smaller element | C++ | |
pair-sum-in-vector | C++ | |
rotate-array-by-n-elements | C++ | |
Sort and Reverse | C++ | |
Back to front | C++ | |
Front to back | C++ | |
Count smaller element | C++ | |
Facing the sun | C++ | |
Student of the year (Descending sorting of vector of pairs) | C++ | |
Find immediate smaller than X | C++ | |
Kth Smallest Element | C++ | |
Alone in Couple | C++ | |
Intro to list | Python | |
Count even odd python | Python | |
Functions in list | Python | |
Pair sum in vector(sum second element of the second element) | C++ | |
Index of the first repeating element | C++ | |
K-th element of two sorted Arrays(merge of two arrays) | C++ | |
Replace all 0's with 5(using atoi) | C++ | |
Third largest element | C++ | |
Find Duplocates in an Array | C++ | |
Majority Element | C++ | |
Max and Second max | C++ |
Sorting
Name | Solution |
---|---|
C generic sort | C++ |
Maximum product of two numbers | C++ |
Count the zeros | C++ |
Bubble sort | C++ |
Amazon binary array sortiong | C++ |
Rotate Matrix by 90 degrees- clowise | C++ |
reverse the columsn of matrix | C++ |
Bubble sort | C++ |
Merge sort | C++ |
Binary array sorting | C++ |
| |C++|
Matrix
Name | Solution |
---|---|
Count zeros | C++ |
Search in matrix | C++ |
Max number of 1s in a row | C++ |
Adding two matrices | C++ |
Transpose matrix (without extraspace) | C++ |
Transpose matrix with extra space | C++ |
two-dimensional-world | C++ |
Rotate Matrix of 90 degrees | C++ |
| |C++|
Strings
Name | Solution 1 | Solution 2 |
---|---|---|
Naive Pattern Search | C++ | |
Lower case | C++ | |
Find maximum number | C++ | |
Print first letter of every word | C++ | |
Reverse string in O(1) space complexity | C++ | |
Display longest name | C++ | |
String validation | Python | |
Repeat the string | Python | |
Welcome abroad | Python | |
Remove spaces | C++ | |
Hello World | Python | |
Check string | C++ | |
Contatenate String python | python | |
Is Isogram | C++ | |
Check for binary | C++ | |
First letter of each word | C++ | |
Missing characters in panagram | C++ | |
Check if b is an anagram of a | C++ | Python |
Consonant and vowals check | C++ | |
Lower to upper case | C++ | |
String validation | C++ | |
C friend function (anagram check) | C++ | |
last-index-of-1 | C++ | |
Longest substring containg 1 | C++ | |
Panagram checking | C++ | |
Repeating characer first appearance leftmost | C++ | |
Uppercase to lowercase | C++ | |
Count numnber of words in a string | C++ | |
Repeated chars | C++ | |
Count distinct vowels in a string | C++ | |
Length of a string | C++ | |
Amend the sentece | C++ | |
Remove 'b' and 'ac' from given string | C++ | |
String sort (Using Quick-sort) | C++ | |
Vowels in string | C++ | |
Check if a string is Isogram or not | C++ | |
Reverse words of a given string | C++ | |
Given two strings, check if one is the anagram of another | Java | |
First and second smallest element | C++ |
| |C++|
Linked List
Name | Solution | Python |
---|---|---|
Fractional linked list | Python | |
Display linked list | C++ | Python |
Nth node from end of linked list | Python | |
Adds two numbers represented by linkedln list | PY | |
Sum of nodes | C++ | |
Intersaction point in y shapped linked list | C++ | |
Remove duplicates in sorted Linked list | C++ | |
Pair swap of a linked list | C++ | |
Find nk-th node in linked list | C++ | |
Linked list insert | C++ | |
Sorted insert for circular linked list | C++ | |
Join two linked list | C++ | |
Modular Node | C++ | |
Delete tail of circular linked list | C++ | |
Delete middle of linked list | C++ | |
Linked list, delete note at position t | C++ | |
Remove head single linked list | C++ | |
Display circular linked list | C++ | |
Compare two circular doubly linked list | C++ | |
Insert at tail (end) of circular linked list | C++ | |
Insert in middle of linked list | C++ | |
Get length(number of nodes) of a circualr linke list | C++ | |
Delete head of a circular list | C++ | |
Insert at head in a circular linked list | C++ | |
Insert at end of a circular linked list | C++ | |
Delete node of Circular list at a specific position | C++ | |
Doubly linked list head insert | C++ | |
Display circular double linked list | C++ | |
Doubly linked list tail insert | C++ | |
Max and minimum in linked list | C++ | |
Delete tail of linked list | C++ | |
Display double linked list forward and backward | C++ | |
Get middle element of circular double linked list | C++ | |
Delete head of doubly linked list | C++ | |
delete-tail-of-doubly-linked-list.cpp | C++ | |
Search in Linked list | C++ | |
Learning struct | C++ | |
Insert node in doubly linked list | C++ | |
Insert node in doubly-linked-list | C++ | |
Is doubly doubly linked list circular | C++ | |
Compare two linked list | C++ | |
Count nodes in Liked List | C++ | |
Count Occurrency | C++ | |
Identical Linked List | C++ | |
Delete a node in single linked list | C++ | |
Insert in sorted linked list | C++ | |
linked-list-length-even-or-odd | C++ | |
Middle Element | C++ | |
Node at the given position | C++ | Python |
Find sum of last N nodes | C++ | |
Circular Linked List | C++ | |
Reverse a Linked List | C++ | |
Detect a loop | C++ | |
Remove loop from Linked List | C++ | |
Check if a Linked LIst is Palindrome | C++ | |
Find lenght of a loop | C++ | |
Occurrence of an integer in a linked list | C++ | |
Sort Linked list of 0s, 1s and 2 | C++ | Pythons |
Remove node without having reference of the head node | C++ |
Stack
Name | Solution |
---|---|
Stack designer | C++ |
Operations on stack | C++ |
Insert in stack | C++ |
Middle of stack | C++ |
Reverse array using stack | C++ |
Reverse string using Stack | C++ |
Implement stack with array | C++ |
Implement stack using Linked List | C++ |
Sort a stack | C++ |
Removing consecutive characters | C++ |
Remove repaeated consecutive digits in a number | C++ |
Queue and Dequeu
Name | Solution |
---|---|
Queue Designer - Queue Push & Pop | C++ |
Queue using an array | C++ |
Dequeu implementation | C++ |
Implement queue using linked list | C++ |
Reverse first K elements of a queue | C++ |
Queue reversal (Reverse content of a Queue) | C++ |
Queue Operations | Java |
Operations in queue | C++ |
Left and right rotation | C++ |
Set
Name | Solution |
---|---|
Set operations | C++ |
Multiset Operator | C++ |
Map
Name | Solution |
---|---|
Multimap operations | C++ |
Map operations | C++ |
Print distinct element | C++ |
Count NON repeating elements | C++ |
Non repeating character | C++ |
First repeating element | C++ |
First eleemnt to accout k times | C++ |
Find the odd occurrenci | C++ |
Count element occurrences | C++ |
Number containgin 1, 2 and 3 | C++ |
Winner of an election | C++ |
Twice counter | C++ |
Heap
Name | Solution |
---|---|
K-largest-elements | C++ |
Search
Name | Solution |
---|---|
Binary Search | C++ |
Peak element | C++ |
Number of occurrence | C++ |
||C++|
Tree-and-Binary-Search-Tree
Name | Solution |
---|---|
Binary Search | C++ |
Min in BST | C++ |
Count Number of leaves node | C++ |
Level Order(Splitting every line with '$' | C++ |
Level order of a binary search tree | C++ |
Inorder of a BST(Binary Search Tree) | C++ |
PostOrder of a BST | C++ |
Preorder of BST | C++ |
Kth largest element in BST | C++ |
Mirror Tree | C++ |
Level order traversal of a tree | C++ |
Left view of a binary tree | C++ |
Sum of leaf nodes (Tree) | C++ |
Search Element in BST | C++ |
search-a-node-in-bst | C++ |
Insert a node in a BST | C++ |
Size of a binary tree | C++ |
Inorder traversal | C++ |
Preorder traversal | C++ |
Postorder traversal | C++ |
Are two trees equals | C++ |
Sum of Binary Tree | C++ |
Sum of leaf nodes in BST | C++ |
K distance from root | C++ |
Lowest Commond Ancestor in a BST | C++ |
Inorder traversal and BST | C++ |
Count leaves in binary tree | C++ |
Couunt BST nodes that lie a given range | C++ |
Graph
Name | Solution |
---|---|
Sum of depenncies in a graph | C++ |
BFS of a graph | C++ |
Print adjacency list | C++ |
Math and BitMagic
Name | Solution |
---|---|
Reverse digits (without strings) | C++ |
Multiplication under modulo | C++ |
Addition under modulo | C++ |
Power of two checker (using ceil and floor) | C++ |
Find position of set bit | C++ |
Maximize toys | C++ |
Factorial of a number | C++ |
Check wheather kth bit is set(return (n>>k)&1;) | C++ |
Check if k bit is set | C++ |
Absolute Value | C++ |
Convert Celsius To Fahrenheit | C++ |
Count numbers divisible by M | C++ |
armstrong-numbers | C++ |
Sqare rootC++ | |
automorphic numbers | C++ |
For loop prime check | C++ |
Int-to-binary | C++ |
Digits in factorial | C++ |
find-prime-numbers-in-a-range | C++ |
Strong numbers | C++ |
Pairs with difference k | C++ |
Power of 2 | C++ |
Count Number of set bits | C++ |
Number is Sparse or not | C++ |
Prime number check with N <= 10^9 | C++ |
the-dice-problem | C++ |
for-loop-prime-check | Java |
Sum digits of a number | Python |
Find first set bit | C++ |
Recursion
Name | Solution |
---|---|
COunt number of digits using recursion | C++ |
Contribute
- Star the repositor
- Fork the repository
- Do the desired changes
- Make a pull request
Contribution essentials note:
- The first row of the solution must contain a comment with the link to the problem
- The commit message must be : "Adds solution full-problem-name"
- The solution must be reported in the solution list in the README.md file.
When to contribute?
- If there is no solution to a problem in the main branch.
- If your solution is asymptotically faster than the one in the main branch.
- If your algorithm is of the same time complexity but with reduced code size. In this case, comment out the original solution and make a pull request with your solution.
- If you have another method of solving the problem which is asymptotically slower than the original method then, comment your solution in the main file and make a pull request.
Mind that
Constructive criticisms or code reviews of any kind are very much welcome.
If you have any questions about the solutions you can find here, feel free to contact me at: [email protected]