"Problem of the Day"
Solve this question to get points.
Given an array of size N containing only 0s, 1s, and 2s; sort the array in ascending order.
Full Problem: https://bit.ly/3y1cqPb
Solve this question to get points.
Given an array of size N containing only 0s, 1s, and 2s; sort the array in ascending order.
Full Problem: https://bit.ly/3y1cqPb
practice.geeksforgeeks.org
Sort an array of 0s, 1s and 2s | Practice | GeeksforGeeks
Given an array of size N containing only 0s, 1s, and 2s; sort the array in ascending order.
Example 1:
Input:
N = 5
arr[]= {0 2 1 2 0}
Output:
0 0 1 2 2
Explanation:
0s 1s and 2s are segregated
into ascending order.
Example 2:
Example 1:
Input:
N = 5
arr[]= {0 2 1 2 0}
Output:
0 0 1 2 2
Explanation:
0s 1s and 2s are segregated
into ascending order.
Example 2:
π6
"Problem of the Day"
Solve this question to get points.
There are n people standing in a circle (numbered clockwise 1 to n) waiting to be executed.
Full Problem: https://bit.ly/3fvaqIt
Solve this question to get points.
There are n people standing in a circle (numbered clockwise 1 to n) waiting to be executed.
Full Problem: https://bit.ly/3fvaqIt
practice.geeksforgeeks.org
Find the Safe Position | Practice | GeeksforGeeks
There are n people standing in a circle (numbered clockwise 1 to n) waiting to be executed. The counting begins at point 1 in the circle and proceeds around the circle in a fixed direction (clockwise). In each step, a certain number of people are ski
π2π1
Must Do-DSA Topics: Day 4
Matrix: 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 or brackets. To understand this concept: https://bit.ly/3CiLrRB
Subarray: A subarray is a contiguous part of an array, i.e., a Subarray is an array that is inside another array. In general, for an array of size n, there are n*(n+1)/2 non-empty subarrays. Find problems based on the difficult levels here: https://bit.ly/3rpXmXj
Subset: If a Set has all its elements belonging to other sets, this set will be known as a subset of the other set. A Subset is denoted as βββ. If set A is a subset of set B, it is represented as A β B. Find problems based on the difficult levels here: https://bit.ly/3rpXmXj
Find more topics of arrays and problems associated with it here: https://bit.ly/3UNBGBW
Matrix: 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 or brackets. To understand this concept: https://bit.ly/3CiLrRB
Subarray: A subarray is a contiguous part of an array, i.e., a Subarray is an array that is inside another array. In general, for an array of size n, there are n*(n+1)/2 non-empty subarrays. Find problems based on the difficult levels here: https://bit.ly/3rpXmXj
Subset: If a Set has all its elements belonging to other sets, this set will be known as a subset of the other set. A Subset is denoted as βββ. If set A is a subset of set B, it is represented as A β B. Find problems based on the difficult levels here: https://bit.ly/3rpXmXj
Find more topics of arrays and problems associated with it here: https://bit.ly/3UNBGBW
π6
"Problem of the Day"
Solve this question to get points.
Given a boolean 2D matrix grid of size n * m. You have to find the number of distinct islands where a group of connected 1s (horizontally or vertically) forms an island.
Full Problem: https://practice.geeksforgeeks.org/problems/number-of-distinct-islands/1
Solve this question to get points.
Given a boolean 2D matrix grid of size n * m. You have to find the number of distinct islands where a group of connected 1s (horizontally or vertically) forms an island.
Full Problem: https://practice.geeksforgeeks.org/problems/number-of-distinct-islands/1
practice.geeksforgeeks.org
Number of Distinct Islands | Practice | GeeksforGeeks
Given a boolean 2D matrix grid of size n * m. You have to find the number of distinct islands where a group of connected 1s (horizontally or vertically) forms an island. Two islands are considered to be distinct if and only if one island is not
π5
"Problem of the Day"
Solve this question to get points.
Given string str of length N. The task is to find the minimum characters to be added at the front to make string palindrome.
Full Problem: https://bit.ly/3LWG3Xv
Solve this question to get points.
Given string str of length N. The task is to find the minimum characters to be added at the front to make string palindrome.
Full Problem: https://bit.ly/3LWG3Xv
practice.geeksforgeeks.org
Minimum characters to be added at front to make string palindrome | Practice | GeeksforGeeks
Given string str of length N. The task is to find the minimum characters to be added at the front to make string palindrome.
Note: A palindrome is a word which reads the same backward as forward. Example: "madam".
Example
Note: A palindrome is a word which reads the same backward as forward. Example: "madam".
Example
π6
π¨Get ready for 7 days of LIVE learning with the best-in-industry mentors!
Register for 1, or register for them all π€ . We bring Free learning for you all-
System Design Mock Interview: https://bit.ly/3SI796O
Must Know Concepts of SpringBoot: https://bit.ly/3fyNyrA
SDE Preparation in 4 Hours: https://bit.ly/3UN9v6p
How is CP helping in SDE Roles: https://bit.ly/3LYJ9tV
GATE Preparation Strategy: https://bit.ly/3BZECD1
Building an E-Commerce App using React: https://bit.ly/3LWICZs
IMDB Data Analysis and Movie Recommendations: https://bit.ly/3LZ6hbV
.
.
And don't forget to share with your friends who might benefit from this! π€
Register for 1, or register for them all π€ . We bring Free learning for you all-
System Design Mock Interview: https://bit.ly/3SI796O
Must Know Concepts of SpringBoot: https://bit.ly/3fyNyrA
SDE Preparation in 4 Hours: https://bit.ly/3UN9v6p
How is CP helping in SDE Roles: https://bit.ly/3LYJ9tV
GATE Preparation Strategy: https://bit.ly/3BZECD1
Building an E-Commerce App using React: https://bit.ly/3LWICZs
IMDB Data Analysis and Movie Recommendations: https://bit.ly/3LZ6hbV
.
.
And don't forget to share with your friends who might benefit from this! π€
π₯7π1
Hey Geeks, π€
In our Must Do-DSA Topics module, we covered Arrays in the previous week.
We hope you've learned the concepts and practiced with the practice problems.
Here you can find every topic that we'll be covering every week: https://bit.ly/3fykVe8
In our Must Do-DSA Topics module, we covered Arrays in the previous week.
We hope you've learned the concepts and practiced with the practice problems.
Here you can find every topic that we'll be covering every week: https://bit.ly/3fykVe8
π2
"Problem of the Day"
Solve this question to get points.
Find the sum of all the numbers between the range l and r. Here each number is represented by the sum of its prime factors.
Full Problem: https://bit.ly/3dYohqb
Solve this question to get points.
Find the sum of all the numbers between the range l and r. Here each number is represented by the sum of its prime factors.
Full Problem: https://bit.ly/3dYohqb
practice.geeksforgeeks.org
Modified Numbers and Queries | Practice | GeeksforGeeks
Find the sum of all the numbers between the range l and r. Here each number is represented by the sum of its prime factors.
Note : For example, 6 is represented by 5 because 6 has two prime factors 2 and 3 and 2 + 3 = 5.
Example 1
Note : For example, 6 is represented by 5 because 6 has two prime factors 2 and 3 and 2 + 3 = 5.
Example 1
π₯8π1
Must Do-DSA Topics: Day 5
Searching: The process of finding the desired information from the set of items stored in the form of elements in the computer memory is referred to as 'searching in data structure'.
Find the element that appears once:
Letβs understand this problem where all numbers occur twice except one number which occurs once in a given array.
We will be using two approaches, learn both these approaches: https://bit.ly/3Ebi9FP
Equilibrium index of an array:
The equilibrium index of an array is an index such that the sum of elements at lower indexes is equal to the sum of elements at higher indexes.
Given a sequence arr[] of size n, Write a function int equilibrium(int[] arr, int n) that returns an equilibrium index (if any) or -1 if no equilibrium index exists.
To delve more into it: https://bit.ly/3UQr0Tn
You can find more here: https://bit.ly/3UNBGBW
Searching: The process of finding the desired information from the set of items stored in the form of elements in the computer memory is referred to as 'searching in data structure'.
Find the element that appears once:
Letβs understand this problem where all numbers occur twice except one number which occurs once in a given array.
We will be using two approaches, learn both these approaches: https://bit.ly/3Ebi9FP
Equilibrium index of an array:
The equilibrium index of an array is an index such that the sum of elements at lower indexes is equal to the sum of elements at higher indexes.
Given a sequence arr[] of size n, Write a function int equilibrium(int[] arr, int n) that returns an equilibrium index (if any) or -1 if no equilibrium index exists.
To delve more into it: https://bit.ly/3UQr0Tn
You can find more here: https://bit.ly/3UNBGBW
π2
"Problem of the Day"
Solve this question to get points.
The task is to count all the possible paths from the top left to the bottom right of a m X n matrix with the constraints that from each cell you can either move only to the right or down.
Full Problem: https://bit.ly/3rsdec1
Solve this question to get points.
The task is to count all the possible paths from the top left to the bottom right of a m X n matrix with the constraints that from each cell you can either move only to the right or down.
Full Problem: https://bit.ly/3rsdec1
practice.geeksforgeeks.org
Count all possible paths from top left to bottom right | Practice | GeeksforGeeks
The task is to count all the possible paths from top left to bottom right of a m X n matrix with the constraints that from each cell you can either move only to right or down.
Example 1:
Input: m = 2, n = 2
Output: 2
Example 1:
Input: m = 2, n = 2
Output: 2
Must Do-DSA Topics: Day 6
Leaders in an array: Write a program to print all the LEADERS in the array. An element is a leader if it is greater than all the elements to its right side. And the rightmost element is always a leader. Weβll be solving these approaches using the different approaches.
To understand more in detail: https://bit.ly/3fI5ik7
Ceiling in a sorted array: Given a sorted array and a value x, the ceiling of x is the smallest element in an array greater than or equal to x, and the floor is the greatest element smaller than or equal to x. Assume that the array is sorted in non-decreasing order. Here we have to write efficient functions to find the floor and ceiling of x.
We will be using two approaches:
Approach 1: Linear Search
Approach 2: Binary Search
Find these approaches in detail: https://bit.ly/3e4MRpu
You can find more problems here: https://bit.ly/3UNBGBW
Leaders in an array: Write a program to print all the LEADERS in the array. An element is a leader if it is greater than all the elements to its right side. And the rightmost element is always a leader. Weβll be solving these approaches using the different approaches.
To understand more in detail: https://bit.ly/3fI5ik7
Ceiling in a sorted array: Given a sorted array and a value x, the ceiling of x is the smallest element in an array greater than or equal to x, and the floor is the greatest element smaller than or equal to x. Assume that the array is sorted in non-decreasing order. Here we have to write efficient functions to find the floor and ceiling of x.
We will be using two approaches:
Approach 1: Linear Search
Approach 2: Binary Search
Find these approaches in detail: https://bit.ly/3e4MRpu
You can find more problems here: https://bit.ly/3UNBGBW
π7π₯1
"Problem of the Day"
Solve this question to get points.
Geek has a list Li containing (not necessarily distinct) N words and Q queries. Each query consists of a string x.
Full Problem: https://bit.ly/3fIQjGQ
Solve this question to get points.
Geek has a list Li containing (not necessarily distinct) N words and Q queries. Each query consists of a string x.
Full Problem: https://bit.ly/3fIQjGQ
practice.geeksforgeeks.org
Geek and Strings | Practice | GeeksforGeeks
Geek has a list Li containing (not necessarily distinct) N words and Q queries. Each query consists of a string x. For each query, find how many strings in the List Li has the string x as its prefix.
Example 1:
Input:
N = 5, Q = 5
Example 1:
Input:
N = 5, Q = 5
Must Do-DSA Topics: Day 7
Two Pointers Technique: Two pointers is really an easy and effective technique that is typically used for searching pairs in a sorted array. The algorithm basically uses the fact that the input array is sorted. We start the sum of extreme values (smallest and largest) and conditionally move both pointers.
Understand the Two Pointers Technique: https://bit.ly/3fJTCNL
Find the peak elements: Here you are given an array arr[] of integers, where you have to find a peak element i.e. an element that is not smaller than its neighbors.
Note: For corner elements, we need to consider only one neighbor.
Weβll be using the below approaches:
1) Naive Approach
2) Find a peak element using recursive Binary Search
3) Find a peak element using iterative Binary search
To delve into it: https://bit.ly/3e5fwuK
You can find more problems to understand Searching more here: https://bit.ly/3UNBGBW
Two Pointers Technique: Two pointers is really an easy and effective technique that is typically used for searching pairs in a sorted array. The algorithm basically uses the fact that the input array is sorted. We start the sum of extreme values (smallest and largest) and conditionally move both pointers.
Understand the Two Pointers Technique: https://bit.ly/3fJTCNL
Find the peak elements: Here you are given an array arr[] of integers, where you have to find a peak element i.e. an element that is not smaller than its neighbors.
Note: For corner elements, we need to consider only one neighbor.
Weβll be using the below approaches:
1) Naive Approach
2) Find a peak element using recursive Binary Search
3) Find a peak element using iterative Binary search
To delve into it: https://bit.ly/3e5fwuK
You can find more problems to understand Searching more here: https://bit.ly/3UNBGBW
π₯4π1
"Problem of the Day"
Solve this question to get points.
Given a string S consisting of only lowercase characters. Find the lexicographically smallest string after removing exactly k characters from the string.
Full Problem: https://bit.ly/3RAU3qZ
Solve this question to get points.
Given a string S consisting of only lowercase characters. Find the lexicographically smallest string after removing exactly k characters from the string.
Full Problem: https://bit.ly/3RAU3qZ
practice.geeksforgeeks.org
Lexicographically smallest string | Practice | GeeksforGeeks
Given a string S consisting of only lowercase characters. Find the lexicographically smallest string after removing exactly k characters from the string. But you have to correct the value of k, i.e., if the length of the string is a po
π2
Must Do-DSA Topics: Day 8
Find a fixed point in a given array: Fixed Point in an array is an index i such that arr[i] is equal to i. Now you are Given an array of n distinct integers sorted in ascending order, and you have to write a function that returns a Fixed Point in the array, if there is any Fixed Point present in array, else returns -1.
We will be understanding this problem using the below approaches:
1) Linear Search
2) Binary Search
To delve into this, check now: https://bit.ly/3Ej4pZB
Find all triplets with zero-sum: Here the task is to find triplets in the array whose sum is zero when you are given an array of distinct elements.
We will be using the naive approach here with-
1) Find all triplets with zero-sum using Hashing
2) Find all triplets with zero-sum using Sorting
To get a deep understanding, check this: https://bit.ly/3rALstS
You can find more problems to understand searching more here: https://bit.ly/3UNBGBW
Find a fixed point in a given array: Fixed Point in an array is an index i such that arr[i] is equal to i. Now you are Given an array of n distinct integers sorted in ascending order, and you have to write a function that returns a Fixed Point in the array, if there is any Fixed Point present in array, else returns -1.
We will be understanding this problem using the below approaches:
1) Linear Search
2) Binary Search
To delve into this, check now: https://bit.ly/3Ej4pZB
Find all triplets with zero-sum: Here the task is to find triplets in the array whose sum is zero when you are given an array of distinct elements.
We will be using the naive approach here with-
1) Find all triplets with zero-sum using Hashing
2) Find all triplets with zero-sum using Sorting
To get a deep understanding, check this: https://bit.ly/3rALstS
You can find more problems to understand searching more here: https://bit.ly/3UNBGBW
π7
"Problem of the Day"
Solve this question to get points.
Given the root of a binary tree, flatten the tree into a "linked list":
Full Problem: https://bit.ly/3SI0ppT
Solve this question to get points.
Given the root of a binary tree, flatten the tree into a "linked list":
Full Problem: https://bit.ly/3SI0ppT
practice.geeksforgeeks.org
Flatten binary tree to linked list | Practice | GeeksforGeeks
Given the root of a binary tree, flatten the tree into a "linked list":
The "linked list" should use the same Node class where the right child pointer points to the next node in the list and the left child pointe
The "linked list" should use the same Node class where the right child pointer points to the next node in the list and the left child pointe
π4
Guess the right answer and take home exclusive rewards! π€©
All you need to do is solve the murder mystery and find out who's the killer. πͺ
Happening on Discord. β
Participate Now: https://discord.gg/pjHTwrtQ
P.S. Don't forget to check out #gfg-contest channel.
All you need to do is solve the murder mystery and find out who's the killer. πͺ
Happening on Discord. β
Participate Now: https://discord.gg/pjHTwrtQ
P.S. Don't forget to check out #gfg-contest channel.
"Problem of the Day"
Solve this question to get points.
Given a String S and an integer K. Find the count of all substrings of length K which have exactly K-1 distinct characters.
Full Problem: https://bit.ly/3RJCVzC
Solve this question to get points.
Given a String S and an integer K. Find the count of all substrings of length K which have exactly K-1 distinct characters.
Full Problem: https://bit.ly/3RJCVzC
practice.geeksforgeeks.org
Substrings of length k with k-1 distinct elements | Practice | GeeksforGeeks
Given a String S and an integer K. Find the count of all substrings of length K which have exactly K-1 distinct characters.
Example 1:
Input:
S = "abcc"
K = 2
Output:
1
Explanation:
Possible substrings of length K =
Example 1:
Input:
S = "abcc"
K = 2
Output:
1
Explanation:
Possible substrings of length K =
π1
"Problem of the Day"
Solve this question to get points.
Ishaan has been given a task by his teacher. He needs to find the Nth term of a series.
Full Problem: https://practice.geeksforgeeks.org/problems/help-ishaan5837/1
Solve this question to get points.
Ishaan has been given a task by his teacher. He needs to find the Nth term of a series.
Full Problem: https://practice.geeksforgeeks.org/problems/help-ishaan5837/1
practice.geeksforgeeks.org
Help Ishaan | Practice | GeeksforGeeks
Ishaan has been given a task by his teacher. He needs to find the Nth term of a series. His teacher gives him some examples to help him out (Refer examples below). He is a bit weak in pattern searching so to help him his teacher told him that the Nth
π3