GeeksforGeeks
17.4K subscribers
1.83K photos
34 videos
24 files
2.76K 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
Problem Of The Day
"Number of Subarrays of 0's"

Solve the problem to win points

You are given an array arr of length N of 0's and 1's. Find the total number of subarrays of 0's

Example 1:

Input:
N = 4
arr[] = {0, 0, 1, 0}
Output:
4
Explanation:
Following are the subarrays of
length 1: {0}, {0}, {0} - 3
length 2: {0, 0} - 1
Total Subarrays: 3 + 1 = 4

Example 2:
Input:
N = 4
arr[] = {0, 0, 0, 0}
Output:
10
Explanation:
Following are the subarrays of
length 1: {0}, {0}, {0}, {0} - 4
length 2: {0, 0}, {0, 0}, {0, 0} - 3
length 3: {0, 0, 0}, {0, 0, 0} - 2
length 4: {0, 0, 0, 0} - 1
Total Subarrays: 4 + 3 + 2 + 1 = 10

Your Task:
Your task is to complete the function no_of_subarrays(), which takes an integer N and an integer array arr as the input parameters and returns an integer denoting the total number of subarrays of 0's.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/0960a833f70b09c59444ea487f99729929fc8910/1

Powered by hirist.com
👍4
Must Learn!💡
'Interview' a term that is exciting and capable of giving stree to some people.

However, it is not a rocket science if you know to speak and when.

This article talks about Object-Oriented Programming interview questions that will surely help you. Give it a read.

Link- https://www.geeksforgeeks.org/oops-interview-questions/?utm_source=Telegram&utm_medium=marketingteam_gfgmain&utm_campaign=oops-interview-questions
👍1
Problem Of The Day
"Median of the Subarrays"

Solve the problem to win points

Given an array A[] of N integers and an integer M. The task is to count the number of subarrays which have median M.
Median of an array is defined as below:

1. If N is odd, the median value is the number that is in the middle after sorting the array.
2. if N is even, the median value is the left of the two middle numbers after sorting the array.

Example 1:
Input:
N = 5, M = 2
A[] = {2, 1, 3, 5, 4}
Output:
3
Explanation:
The subarrays which has median equal to M
are [2], [2,1,3] and [2,1,3,5]

Example 2:
Input:
N = 1, M = 1
A[] = {1}
Output:
1
Explanation:
The subarrays which has median equal to M
is [1].

Your Task:
You don't need to read input or print anything. Complete the function countSubarray( ) which takes the integer N , the array A[], and the integer M as input parameters and returns the number of subarays.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/6f08220ca3b871be594f50f7f56a9ef2799cb485/1

Powered by hirist.com
❤1👍1
🚨Job Alert🚨
Vecmocon Technologies is hiring for Senior Backend Developer.

Location - New Delhi
Experience - 5 - 6 Years
Apply by - Mar 17, 2023

Apply via the following link and share the opportunity with your friends- https://practice.geeksforgeeks.org/jobs/vecmocon-technologies-sr-backend-developer

📢: Also, do not miss the chance to get endless opportunities at Jobs Fair 2023 - https://practice.geeksforgeeks.org/jobs?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=jobfair2023
👍2
Problem Of The Day
"Distinct Difference"

Solve the problem to win points

Given an array A[] of length N. For each index i (1<=i<=N), find the diffference between the number of distinct element in it's left and right side in the array.

Example 1:
Input:
N = 3
arr[] = {4, 3, 3}
Output: {-1, 0, 2}
Explanation: For index i=1, there are 0 distinct element in the left side of it, and 1 distinct element(3) in it's right side. So difference is 0-1 = -1.

Similarly for index i=2, there is 1 distinct element (4) in left side of it, and 1 distinct element(3) in it's right side. So difference is 1-1 = 0.

Similarly for index i=3, there are 2 distinct elements (4 and 3) in left side of it, and 0 distinct elements in it's left side. So difference is 2-0 = 2.

Example 2:
Input:
N = 4
arr[] = {4, 4, 3, 3}
Output: {-2, 0, 0, 2}
Explanation: For index i=1, there are 0 distinct element in the left side of it, and 2 distinct element(4 and 3) in it's right side. So difference is 0-2 = -2.

Similarly for index i=2, there is 1 distinct element (4) in left side of it, and 1 distinct element(3) in it's right side. So difference is 1-1 = 0.

Similarly for index i=4, there are 2 distinct elements (4 and 3) in left side of it, and 0 distinct element in it's right side. So difference is 2-0 = 2.

Your Task:
You don't need to read input or print anything. Your task is to complete the function getDistinctDifference() which takes the array A[] and its size N as input parameters and returns an array containing the difference between number of ditinct elements in left and right side for each 1<=i<=N.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/c670bf260ea9dce6c5910dedc165aa403f6e951d/1

Powered by hirist.com
👍1
Only 1 day left!
Get your dream job at your dream organization.✨🙌

Hurry up!

Link- https://practice.geeksforgeeks.org/jobs?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=jobfair2023
Problem Of The Day
"Shortest XY distance in Grid"

Solve the problem to win points

Give a N*M grid of characters 'O', 'X', and 'Y'. Find the minimum Manhattan distance between a X and a Y.

Manhattan Distance :
| row_index_x - row_index_y | + | column_index_x - column_index_y |

Example 1:
Input:
N = 4, M = 4
grid = {{X, O, O, O}
{O, Y, O, Y}
{X, X, O, O}
{O, Y, O, O}}
Output:
1
Explanation:
{{X, O, O, O}
{O, Y, O, Y}
{X, X, O, O}
{O, Y, O, O}}
The shortest X-Y distance in the grid is 1.
One possible such X and Y are marked in bold
in the above grid.

Example 2:
Input:
N = 3, M = 3
grid = {{X, X, O}
{O, O, Y}
{Y, O, O}}
Output :
2
Explanation:
{{X, X, O}
{O, O, Y}
{Y, O, O}}
The shortest X-Y distance in the grid is 2.
One possible such X and Y are marked in bold
in the above grid.

Your Task:
You don't need to read input or print anything. Your task is to complete the function shortestXYDist() which takes two integers N, and M and an 2D list of size N*M as input and returns the shortest Manhattan Distance between a X and a Y.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/7366ce450d84b55391fc787a681c4d60de359e72/1

Powered by hirist.com
👍1
Must Learn!💡
VPNs are frequently used to safeguard sensitive data, get around geo-restrictions and internet censorship, and access sites that are only accessible on private networks.

There are many excellent VPN services available on the market that provide a variety of features and advantages to support your online security.

This article will introduce you with top 10 VPNs to safeguard your online privacy, unblock material, and browse the internet privately and securely. Give it a read.

Link- https://www.geeksforgeeks.org/10-vpn-services-you-should-consider/?utm_source=Telegram&utm_medium=marketingteam_gfgmain&utm_campaign=10-vpn-services-you-should-consider
👍1👎1
🚨Job Alert🚨
OrangeSkill Technologies is hiring for Dot Net Developer.

Location - Remote
Experience - 3+ Years
Apply by - Mar 31, 2023

Apply via the following link and share the opportunity with your friends- https://practice.geeksforgeeks.org/jobs/OrangeSkill-Dot-Net-Developer?utm_source=Telegram&utm_medium=marketingteam_gfgmain&utm_campaign=OrangeSkill-Dot-Net-Developer

📢: Also, do not miss the chance to get endless opportunities at Jobs Fair 2023 - https://practice.geeksforgeeks.org/jobs/willshall-Sr-Web-Designer-Team-Lead?utm_source=Discord&utm_medium=marketingteam_gfgmain&utm_campaign=willshall-Sr-Web-Designer-Team-Lead
Problem Of The Day
"Taxi Booking"

Solve the problem to win points

You are going to book a taxi. There are infinite number of points 1, 2, 3... on the X axis and your current position is cur. There are N Taxis near you, and the position of those taxis is given as an array pos. Where pos[i] denotes the position of the ith taxi. You are also given an array time. Where time[i] denotes the time taken by the ith taxi to cover 1 unit of distance. Your task is to find the minimum time to board a taxi.

Example 1:
Input:
N = 3, cur = 4
pos = [1, 5, 6]
time = [2, 3, 1]
Output:
2
Explanation:
Total time taken by the 1st taxi will be: (4-1)*2 = 6
Total time taken by the 2nd taxi will be: (5-4)*3 = 3
Total time taken by the 3rd taxi will be: (6-4)*1 = 2
So, the minimum time will be 2 sec.

Example 2:
Input:
N = 2, cur = 1
pos = [1, 6]
time = [10, 3]
Output:
0
Explanation:
Total time taken by the 1st taxi will be: (1-1)*10 = 0
Total time taken by the 2nd taxi will be: (6-1)*3 = 15
So, the minimum time will be 0 sec.

Your Task:
You don't need to read input or print anything. Your task is to complete the function minimumTime() which takes two integers N and cur, and 2 arrays pos, and time as input parameters and returns the minimum time required to board the taxi.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/7995e41d167d81f14f1d4194b29ef839f52d18ba/1

Powered by hirist.com
❤1
Must Learn!💡
Google Chrome is the most popular web browser. It has some amazing features that help to boost productivity.

Chrome extensions are one of the remarkable tools which are helpful and work as a replacement for heavy productivity applications.

This article will introduce you with some best Chrome extensions that will help in enhancing your productivity. Give it a read.

Link- https://www.geeksforgeeks.org/best-chrome-extensions-for-productivity/?utm_source=Telegram&utm_medium=marketingteam_gfgmain&utm_campaign=best-chrome-extensions-for-productivity
Problem Of The Day
"String rp or pr"

Solve the problem to win points

Given a string S. In one operation, you can remove the substring "pr" from the string S and get amount X or you can remove the substring "rp" and get the amount Y.
Find the maximum amount you can get if you perform zero or more such operations optimally.

Note :
Substring of a string S is defined as a continuous sequence of characters in S.
After removing pr or rp, the order of remaining letters should remain the same.

Example 1:
Input:
X = 5, Y = 4
S = "abppprrr"
Output: 15
Explanation:
Here, S = "abppprrr"
X= 5, Y=4.
Remove "pr", new string S = "abpprr".
Remove "pr", new string S = "abpr".
Remove "pr", new string S = "ab".
In total, we removed "pr" 3 times,
so total score is 3*X + 0*Y = 3*5 =15.

Example 2:
Input:
X = 7, Y = 7
S = "prpptppr"
Output: 14
Explanation:
Here, S = "prpptppr"
X= 7, Y=7.
As both have the same amount we can first
remove either pr or rp. Here we start with pr
Remove "pr", new string S = "pptppr".
Remove "pr", new string S = "pptp".
In total, we removed "pr" 2 times,
so total score is 2*X + 0*Y = 2*7 =14.

Your Task:
You don't need to read input or print anything. Your task is to complete the function solve() which takes the X ,Y and string S as input parameters and returns the maximum amount you can get after performing the above operations.


Expected Time Complexity: O(|S|)
Expected Auxiliary Space: O(|S|)

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/d25f415de2ff3e02134de03e17ad019d723ab2e9/1

Powered by hirist.com
👍1🔥1
'Gmail Signature' you must have heard of this feature on Gmail and might have tried to create but failed.

This article will ease the complications and explain the procedure to create your own signature in Gmail. Give it a read.

Link- https://www.geeksforgeeks.org/how-to-create-a-gmail-signature/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=gmailsignature
🚨Job Alert🚨
WillShall is hiring for Php Developer(Shopify & WordPress).

Location - Chandigarh
Experience - 2+ Years
Apply by - Mar 31, 2023

Apply via the following link and share the opportunity with your friends- https://practice.geeksforgeeks.org/jobs/willshall-Php-Developer-Shopify-WordPress?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=willshall-Php-Developer-Shopify-WordPress
❤1
Problem Of The Day
"BST Maximum Difference"

Solve the problem to win points

You are given a Binary Search Tree and a target value. You must find the maximum difference between the sum of node data from root to target and from target to a child leaf node (target exclusive). Initially, you are at the root node.

Note: If the target node is not present in the tree then return -1.

Example 1:
Input:
Target = 20
Output: 10
Explanation: From root to target the sum of node data is 25 and from target to the children leaf nodes the sums of the node data are 15 and 22. So, the maximum difference will be (25-15) = 10.

Example 2:
Input:
Target = 50
Output: -1
Explanation: The target node is not present in the tree.

Your Task:
You don't need to read input or print anything. Your task is to complete the function maxDifferenceBST() which takes BST(you are given the root node of the BST ) and target as input, and returns an interger value as the required answer. If the target is not present in the BST then return -1.

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(H), H - Height of the Tree.

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/e841e10213ddf839d51c2909f1808632a19ae0bf/1

Powered by hirist.com
Must Learn!💡
Microservice is one such service that is responsible for software development.

It helps you to identify future debugging problems and allows you to check architecture for service and performance.

This article talks about microservices design principles in detail that every developer should know. Give it a read.

Link- https://www.geeksforgeeks.org/10-microservices-design-principles-that-every-developer-should-know/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=10microservicesdesign
Problem Of The Day
"Remove and Reverse"

Solve the problem to win points

Given a string S which consists of only lowercase English alphabets, you have to perform the below operations:
If the string S contains any repeating character, remove the first repeating character and reverse the string and again perform the above operation on the modified string, otherwise, you stop.
You have to find the final string.

Example 1:
Input: S = "abab"
Output: ba
Explanation:
In 1st operation: The first repeating
character is a. After Removing the first
character, S = "bab". After Reversing the
string, S = "bab".
In 2nd operation: The first non repeating
character is b. After Removing the first
character, S = "ab". After Reversing the
string, S = "ba".
Now the string S does not contain any
repeating character.

Example 2:
Input: S = "dddd"
Output: d
Your Task:
You don't need to read input or print anything. Your task is to complete the function removeReverse( ) which accepts a string S input parameter and returns the modified string.

Expected Time Complexity: O(|S|)
Expected Auxiliary Space: O(K), K <= 26.

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/1e2f365be6114b671b915e145ec7dbcfdc432910/1

Powered by hirist.com
👍1
Must Learn!💡
Employee Stock Ownership Plan or ESOP is a company's stock owned by employees, which is part of a compensation package, where shares will vest over a period of time.

What benefits do employees and employers get from ESOPs? This article talks about it in detail with the right examples. Give it a read.

Link- https://www.geeksforgeeks.org/how-employees-and-employers-benefits-from-esops/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=benefitsfromesops
Problem Of The Day
"Redundant Parenthesis"

Solve the problem to win points

Given a valid expression containing only binary operators '+', '-', '*', '/' and operands, remove all the redundant parenthesis.

A set of parenthesis is said to be redundant if, removing them, does not change the value of the expression.

Note: The operators '+' and '-' have the same priority. '*' and '/' also have the same priority. '*' and '/' have more priority than '+' and '-'.

Example 1:
Input:
Exp = (A*(B+C))
Output: A*(B+C)
Explanation: The outermost parenthesis
are redundant.

Example 2:
Input:
Exp = A+(B+(C))
Output: A+B+C
Explanation: All the parenthesis
are redundant.

Your Task:
You don't need to read input or print anything. Your task is to complete the function removeBrackets() which takes the string Exp as input parameters and returns the updated expression.

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

Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/ef5111156686a3136c6a0df8bbda17f952947e17/1

Powered by hirist.com
Must Learn!💡
Writing code is hard, and Python programmers often face a steep learning curve.

One of the most common issues that can prevent you from writing readable code is bad practices in organizing your code.

This article will introduce ways to help you avoid making those mistakes and improve your writing of Python code. Give it a read.

Link- https://www.geeksforgeeks.org/10-tips-and-tricks-to-write-the-better-python-code/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=betterpythoncode
👍4😁1