GeeksforGeeks
19.1K subscribers
1.66K photos
34 videos
24 files
2.63K links
Official Hub βœ…

Your coding haven – where tech meets simplicity.

Discover:
πŸ˜‚ Coding Laughter
πŸ“˜ Curated Study Material
πŸ’Ž Exclusive Offers

Utilize every service we provide and make a promise to find better opportunities for yourself! #gfgkarlohojayega!
Download Telegram
Must Do-DSA Topics: Day 9

A Sorting Algorithm is used to rearrange a given array or list of elements according to a comparison operator on the elements.

Stability in sorting algorithms: A sorting algorithm is said to be stable if two objects with equal keys appear in the same order in sorted output as they appear in the input data set. Let’s take a deeper dive into how to make stable sorting algorithms and what needs to be taken care of here: https://bit.ly/3T9Vyh7

Time Complexities of Standard Sorting Algorithms:
Time Complexity is defined as the number of times a particular instruction set is executed rather than the total time taken. It is because the total time taken depends on external factors like the compiler used, the processor’s speed, etc. Find more about types of Time Complexity, Space Complexity, and a quick revision sheet that you may refer to at the last minute here: https://bit.ly/3SV20ZF

You can find everything you need to know here: https://bit.ly/3CiEoHr
πŸ‘6
Media is too big
VIEW IN TELEGRAM
Geek Week is here!!🀩🀩

A weeklong rollercoaster of fun, games, contests, challenges, and HUGE rewards to win!!✨

The wait is over, mark your calendars πŸ—“now from 11th Oct to 17th Oct.

Check it out now: https://bit.ly/3COfSPM
"Problem of the Day"                                                     
                                                     
Solve this question to get points.

Given a string w, integer array b,  character array and an integer nn is the size of array b and array x.

Full Problem: https://practice.geeksforgeeks.org/problems/save-your-life4601/1
πŸ‘2
Must Do-DSA Topics: Day10

Bitonic Sort: Bitonic Sort is a classic parallel algorithm for sorting. The number of comparisons done by Bitonic sort is more than popular sorting algorithms like Merge Sort. To understand Bitonic Sort, we must first understand what is Bitonic Sequence and how to make a given sequence Bitonic: https://bit.ly/3RPSNAp

Iterative merge Sort: This is an example of stable sorting algorithm, as it doesnot change the relative order of same value. Here you will find how to implement iterative merge sort and how it is different from iterative quick sort. https://bit.ly/3SVh7T3

Pigeonhole Sort: Pigeonhole sorting is a sorting algorithm that is suitable for sorting lists of elements where the number of elements and the number of possible key values are approximately the same. Find the working of this algorithm and comparison with counting sort here: https://bit.ly/3RZPMh4

You can find everything you need to know here: https://bit.ly/3CiEoHr
πŸ‘6πŸ”₯1
"Problem of the Day"                                                     
                                                     
Solve this question to get points.

Given an array A of size N of integers. Your task is to find the sum of minimum and maximum element in the array.

Full Problem: https://practice.geeksforgeeks.org/problems/max-min/1
Must Do-DSA Topics: Day 11

Know your sorting algorithm: Ever wondered how sort() function we use in C++/Java or sorted() in Python work internally? Here is a list of all the inbuilt sorting algorithms of different programming languages and the algorithm they use internally. Check it out now: https://bit.ly/3CqpEGs

Comparator function of qsort() in C: Standard C library provides qsort() that can be used for sorting an array. As the name suggests, the function uses QuickSort algorithm to sort the given array. The key point about qsort() is comparator function comparator. Know more about Comparator function here: https://bit.ly/3g7vDbR

Array.sort() in Java with examples: Array class is a class containing static methods that are used with arrays in order to search, sort, compare, insert elements, or return a string representation of an array. Know more about them here: https://bit.ly/3yBFQDt

You can find everything you need to know here: https://bit.ly/3CiEoHr
πŸ‘8❀3πŸ”₯1
Problem Of The Day
"Print Diagonally"

Solve the problem to win points

Give a N * N square matrix A, return all the elements of its anti-diagonals from top to bottom.

Your Task:
You don't need to read input or print anything. Your task is to complete the function downwardDigonal() which takes an integer N and a 2D matrix A[ ][ ] as input parameters and returns the list of all elements of its anti-diagonals from top to bottom.

Find the complete problem and submit your answers here : https://practice.geeksforgeeks.org/problems/print-diagonally4331/1
πŸ‘6πŸ‘4❀1
Must Do-DSA Topics : Day 12

Know your sorting Algorithm | Set 2 : Learn about C++’s Sorting Weapon, Introsort. 
What is Introsort? 
Simply putting, it is the best sorting algorithm around. It is a hybrid sorting algorithm, which means that it uses more than one sorting algorithms as a routine. 
Checkout more here :
https://bit.ly/3eDblXf

Collections.sort() in Java with Examples : java.util.Collections.sort() method is present in java.util.Collections class. It is used to sort the elements present in the specified list of Collection in ascending order.
Checkout more here : https://bit.ly/3CGPVQX

std::sort() in C++ STL :
C++ STL provides a similar function sort (like qsort in C) that sorts a vector or array (items with random access)

It generally takes two parameters, the first one being the point of the array/vector from where the sorting needs to begin.
Checkout more : https://bit.ly/3MMlOfG

You can find everything you need to know here : https://bit.ly/3CiEoHr
πŸ‘3
Problem Of The Day
"Hamiltonian Path"

Solve the problem to win points

A Hamiltonian path, is a path in an undirected graph that visits each vertex exactly once. Given an undirected graph, the task is to check if a Hamiltonian path is present in it or not.

Example 1:

Input:
N = 4, M = 4
Edges[][]= { {1,2}, {2,3}, {3,4}, {2,4} }
Output:
1
Explanation:
There is a hamiltonian path:
1 -> 2 -> 3 -> 4

Your task:
You don't need to read input or print anything. Your task is to complete the function check() which takes the N (the number of vertices), M (Number of edges) and the list of Edges[][] (where Edges[i] denotes the undirected Edge between vertices Edge[i][0] and Edges[i][1] ) as input parameter and returns true (boolean value) if the graph contains Hamiltonian path,otherwise returns false.


Expected Time Complexity: O(N!).
Expected Auxiliary Space: O(N+M).

Solve the problem and submit your answers here : https://practice.geeksforgeeks.org/problems/hamiltonian-path2522/1
πŸ‘4
Must Do DSA Topics day 13
Matrix
What is Matrix in Data Structure?

A matrix represents a collection of numbers arranged in an order of rows and columns. It is necessary to enclose the elements of a matrix in parentheses/brackets.

Rotate elements in a Matrix : The idea is to use loops similar to the program for printing a matrix in spiral form. One by one rotate all rings of elements, starting from the outermost. To rotate a ring, we need to do following.
Move elements of top row.
Move elements of last column.
Move elements of bottom row.
Move elements of first column.
Learn more : https://bit.ly/3MHLE4e

Inplace rotate square matrix by 90 degrees | Set 1:
Given a square matrix, turn it by 90 degrees in an anti-clockwise direction without using any extra space
Learn more : https://bit.ly/3gmaV8c

Rotate a matrix by 90 degree without using any extra space | Set 2 : Given a square matrix, turn it by 90 degrees in anti-clockwise direction without using any extra space.
Learn More : https://bit.ly/3D65suZ
❀3πŸ‘2
Problem Of The Day
"Number Formation"

Solve the problem to win points

Given three integers x, y, and z, the task is to find the sum of all the numbers formed by
having 4 at most x times, having 5 at most y times, and having 6 at most z times as a digit.

Note: Output the sum modulo 109+7.

Example 1:

Input: X = 1, Y = 1, Z = 1
Output: 3675
Explanation: 4 + 5 + 6 + 45 + 54 + 56
+ 65 + 46 + 64 + 456 + 465
+ 546 + 564 + 645 + 654 = 3675

Your Task:
You don't need to read input or print anything. Complete the function getSum() which takes X, Y and Z as input parameters and returns the integer value

Solve the problem and submit your answers here: https://practice.geeksforgeeks.org/problems/number-formation3506/1
πŸ”₯4πŸ‘3
Must Do DSA Topics day 14

Matrix

Rotate a Matrix by 180 degree : Given a square matrix, the task is that we turn it by 180 degrees in an anti-clockwise direction without using any extra space.
Learn more here : https://bit.ly/3DbeBTa

Rotate each ring of matrix anticlockwise by K elements : Given a matrix of order M*N and a value K, the task is to rotate each ring of the matrix anticlockwise by K elements. If in any ring elements are less than and equal K then don’t rotate it.
Learn more here : https://bit.ly/3EXCXRq

Turn an image by 90 degree : Given an image, how will you turn it by 90 degrees? A vague question. Minimize the browser and try your solution before going further. An image can be treated as 2D matrix which can be stored in a buffer. We are provided with matrix dimensions and it’s base address.
Learn more here : https://bit.ly/3COqddo
❀4πŸ‘2
Must Do DSA Topics day 15
Matrix

Check if all rows of a matrix are circular rotations of each other : Given a matrix of n*n size, the task is to find whether all rows are circular rotations of each other or not.
Learn more here : https://bit.ly/3eQhwHv


Sort the given matrix : Given a n x n matrix. The problem is to sort the given matrix in strict order. Here strict order means that the matrix is sorted in a way such that all elements in a row are sorted in increasing order and for row β€˜i’, where 1 <= i <= n-1, the first element of row β€˜i’ is greater than or equal to the last element of row β€˜i-1’.
Learn more here : https://bit.ly/3sfdNpX


Find the row with maximum number of 1s : Given a boolean 2D array, where each row is sorted. Find the row with the maximum number of 1s.
Example:
Input matrix
0 1 1 1
0 0 1 1
1 1 1 1 // this row has maximum 1s
0 0 0 0
Output: 2
Learn more here : https://bit.ly/3TI0YjS
πŸ‘3
Problem Of The Day
Filling Bucket
Solve the problem to win points
Given a Bucket having a capacity of N litres and the task is to determine that by how many ways you can fill it using two bottles of capacity of 1 Litre and 2 Litre only. Find the answer modulo 108.

Example 1:

Input:
3
Output:
3
Explanation:
Let O denote filling by 1 litre bottle and
T denote filling by 2 litre bottle.
So for N = 3, we have :
{OOO,TO,OT}. Thus there are 3 total ways.

Your Task:
You don't need to read input or print anything. Your task is to complete the function fillingBucket() which takes an Integer N as input and returns the number of total ways possible.

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)

Solve the problem and submit your answers here : https://practice.geeksforgeeks.org/problems/filling-bucket0529/1
πŸ‘4
Must Do DSA Topics, day 16
Matrix

Find median in row wise sorted matrix :
We are given a row-wise sorted matrix of size r*c, we need to find the median of the matrix given. It is assumed that r*c is always odd.

Examples:
Input: 1 3 5
2 6 9
3 6 9
Output: Median is 5
If we put all the values in a sorted
array A[] = 1 2 3 3 5 6 6 9 9)

Input: 1 3 4
2 5 6
7 8 9
Output: Median is 5
Learn more here : https://bit.ly/3VY4YP1

Matrix Multiplication | Recursive :
Given two matrices A and B. The task is to multiply matrix A and matrix B recursively. If matrix A and matrix B are not multiplicative compatible, then generate output β€œNot Possible”.
Learn more : https://bit.ly/3VY2EYa

Program to multiply two matrices :
Given two matrices, the task is to multiply them. Matrices can either be square or rectangular.
Learn more here : https://bit.ly/3gG47Cg
πŸ‘8
Problem of the day
"The Smurfs"

Solve the problem to win points

A geek once visited a magical island where he found a special creature. He named it as Smurf. He noticed a very strange thing there. The smurfs resembled the primary colors of light. To make it more clear, the primary colors of light are Red(R), Green(G), and Blue(B). He talked to one of the smurfs. The smurfs came to know that he is a good programmer. The smurfs suggested a deal that they will ask him one question and if he is able to answer that question, they will allow the geek to take anything from the island.
The question is as follows:
The smurfs possess a very magical property. When two smurfs of different colors meet with other, they gets converted into a smurf of the third color. How many minimum number of smurfs will be remaining after this transformation? The question looked simple to geek. However, the smurfs put another constraint to make the geek think more. The two smurfs must be adjacent to each other to make the transformation take place. There are n smurfs the colors of which are given in an array a[].

Example 1:

Input: n = 5
a = {'R' , 'G', 'B', 'R', 'B'}
Output: 1
Explaination: First 'R' and 'G' makes 'B'.
Then 'B' and 'R' makes 'G' and that 'G'
with 'B' at index 2 makes 'R', Now the 'R'
and the last 'B' makes 'G'.
Example 2:

Input: n = 2
a = {'R', 'R'}
Output: 2
Explaination: There are two 'R' s. So
they cannot change to anything else.
Your Task:
You do not need to read input or print anything. Your task is to complete the function findMin() which takes n and a as input parameters and retunrs the minimum number of smurfs existing at the end.

Expected Time Complexity: O(n)
Expected Auxiliary Space: O(1)

Solve the problem and submit your answers here : https://practice.geeksforgeeks.org/problems/the-smurfs4201/1
πŸ‘4
Problem Of The Day
"Print leaf nodes from preorder traversal of BST"

Solve the problem to win points

Example 1:

Input:
N = 2
arr = {2,1}
Output: {1}
Explaination: 1 is the only leaf node.

Example 2:

Input:
N = 3
Arr = {3, 2, 4}
Output: {2, 4}
Explaination: 2, 4 are the leaf nodes.

Your Task:
You don't need to read input or print anything. Your task is to complete the function leafNodes() which takes the array arr[] and its size N as input parameters and returns the leaf nodes of the tree.


Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)

Solve the problem and submit your answers here : https://practice.geeksforgeeks.org/problems/print-leaf-nodes-from-preorder-traversal-of-bst2657/1
πŸ‘3πŸ‘1
Must Do DSA Topics day 17
Hashing

Introduction : Hashing is a popular technique for storing and retrieving data as fast as possible.Hashing gives optimal results as it performs optimal searches.
Learn more : https://bit.ly/3sAvsZm

Index Mapping (or Trivial Hashing) with negatives allowed : Given a limited range array contains both positive and non-positive numbers, i.e., elements are in the range from -MAX to +MAX. Our task is to search if some number is present in the array or not in O(1) time.
Since range is limited, we can use index mapping (or trivial hashing). We use values as the index in a big array. Therefore we can search and insert elements in O(1) time.
Learn more : https://bit.ly/3N9FJVO

Separate Chaining Collision Handling Technique in Hashing : The idea behind separate chaining is to implement the array as a linked list called a chain. Separate chaining is one of the most popular and commonly used techniques in order to handle collisions.
Learn more : https://bit.ly/3FlpVgQ
πŸ‘5