Problem Of The Day
"Frogs and Jumps"
Solve the problem to win points
N frogs are positioned at one end of the pond. All frogs want to reach the other end of the pond as soon as possible. The pond has some leaves arranged in a straight line. Each frog has the strength to jump exactly K leaves. For example, a frog having strength 2 will visit the leaves 2, 4, 6, ... etc. while crossing the pond.
Given the strength of each frog and the number of leaves, your task is to find the number of leaves that not be visited by any of the frogs when all frogs have reached the other end of the pond.
Example 1:
Input:
N = 3
leaves = 4
frogs[] = {3, 2, 4}
Output: 1
Explanation:
Leaf 1 will not be visited by any frog.
Example 2:
Input:
N = 3
leaves = 6
frogs[] = {1, 3, 5}
Output: 0
Explanation:
First frog will visit all the leaves so no
leaf is left unvisited.
Your Task:
Complete the function unvisitedLeaves() which takes the integers N, leaves and the array frogs as the input parameters, and returns the number of unvisited leaves.
Expected Time Complexity: O(N*log(leaves))
Expected Auxiliary Space: O(leaves)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/5551749efa02ae36b6fdb3034a7810e84bd4c1a4/1
Powered by hirist.com
"Frogs and Jumps"
Solve the problem to win points
N frogs are positioned at one end of the pond. All frogs want to reach the other end of the pond as soon as possible. The pond has some leaves arranged in a straight line. Each frog has the strength to jump exactly K leaves. For example, a frog having strength 2 will visit the leaves 2, 4, 6, ... etc. while crossing the pond.
Given the strength of each frog and the number of leaves, your task is to find the number of leaves that not be visited by any of the frogs when all frogs have reached the other end of the pond.
Example 1:
Input:
N = 3
leaves = 4
frogs[] = {3, 2, 4}
Output: 1
Explanation:
Leaf 1 will not be visited by any frog.
Example 2:
Input:
N = 3
leaves = 6
frogs[] = {1, 3, 5}
Output: 0
Explanation:
First frog will visit all the leaves so no
leaf is left unvisited.
Your Task:
Complete the function unvisitedLeaves() which takes the integers N, leaves and the array frogs as the input parameters, and returns the number of unvisited leaves.
Expected Time Complexity: O(N*log(leaves))
Expected Auxiliary Space: O(leaves)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/5551749efa02ae36b6fdb3034a7810e84bd4c1a4/1
Powered by hirist.com
practice.geeksforgeeks.org
Frogs and Jumps | Practice | GeeksforGeeks
N frogs are positioned at one end of the pond. All frogs want to reach the other end of the pond as soon as possible. The pond has some leaves arranged in a straight line. Each frog has the strength to jump exactly K leaves. For e
π3
π¨Job Alertπ¨
Smartcoin is hiring for Senior Software Engineer .
Location - Bangalore
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/Smartcoin-sr-soft-engg
Smartcoin is hiring for Senior Software Engineer .
Location - Bangalore
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/Smartcoin-sr-soft-engg
Problem Of The Day
"Divide in Incremental Groups"
Solve the problem to win points
Given two integers N and K, the task is to count the number of ways to divide N into K groups of positive integers such that their sum is N and the number of elements in groups follows a non-decreasing order (i.e. group[i] <= group[i+1]).
Example 1:
Input:
N = 8
K = 4
Output:
5
Explanation:
There are 5 groups such that their sum is 8
and the number of positive integers in each
group is 4. The 5 groups are [1, 1, 1, 5],
[1, 1, 2, 4], [1, 1, 3, 3], [1, 2, 2, 3] and
[2, 2, 2, 2].
Example 2:
Input:
N = 4
K = 3
Output:
1
Explanation:
The only possible grouping is {1, 1, 2}. Hence,
the answer is 1 in this case.
Your Task:
Complete the function countWaystoDivide() which takes the integers N and K as the input parameters, and returns the number of ways to divide the sum N into K groups.
Expected Time Complexity: O(N2*K)
Expected Auxiliary Space: O(N2*K)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/c239059f6d110e6778cc2f2a1ab58ffd0a3d64ca/1
Powered by hirist.com
"Divide in Incremental Groups"
Solve the problem to win points
Given two integers N and K, the task is to count the number of ways to divide N into K groups of positive integers such that their sum is N and the number of elements in groups follows a non-decreasing order (i.e. group[i] <= group[i+1]).
Example 1:
Input:
N = 8
K = 4
Output:
5
Explanation:
There are 5 groups such that their sum is 8
and the number of positive integers in each
group is 4. The 5 groups are [1, 1, 1, 5],
[1, 1, 2, 4], [1, 1, 3, 3], [1, 2, 2, 3] and
[2, 2, 2, 2].
Example 2:
Input:
N = 4
K = 3
Output:
1
Explanation:
The only possible grouping is {1, 1, 2}. Hence,
the answer is 1 in this case.
Your Task:
Complete the function countWaystoDivide() which takes the integers N and K as the input parameters, and returns the number of ways to divide the sum N into K groups.
Expected Time Complexity: O(N2*K)
Expected Auxiliary Space: O(N2*K)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/c239059f6d110e6778cc2f2a1ab58ffd0a3d64ca/1
Powered by hirist.com
practice.geeksforgeeks.org
Divide in Incremental Groups | Practice | GeeksforGeeks
Given two integers N and K, the task is to count the number of ways to divide N into K groups of positive integers such that their sum is N and the number of elements in groups follows a non-decreasing order (i.e. group[i] <= group[i+1]).
β€1π1
Flutter is Googleβs Mobile SDK to build native iOS and Android, Desktop (Windows, Linux, macOS), and Web apps from a single codebase.
When building applications with Flutter everything is towards Widgets β the blocks with which the flutter apps are built.
This article will take you through some best practices for designing user interfaces in Flutter. Give it a read.
Link- https://www.geeksforgeeks.org/best-practices-for-designing-user-interfaces-in-flutter/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=bestpracticesfordesigninguserinterfacesinflutter
When building applications with Flutter everything is towards Widgets β the blocks with which the flutter apps are built.
This article will take you through some best practices for designing user interfaces in Flutter. Give it a read.
Link- https://www.geeksforgeeks.org/best-practices-for-designing-user-interfaces-in-flutter/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=bestpracticesfordesigninguserinterfacesinflutter
π1
Problem Of The Day
"Shy Geek"
Solve the problem to win points
Geek went to buy some chocolates from a nearby shop with k coins in his pocket. He found that the shop contains n chocolates which are arranged in sorted order (increasing) of their prices.
Now geek wants to taste costlier chocolates so he decided that he will buy the costliest chocolate (of course among the ones that he can afford) till there exists at least one type of chocolate he can afford. You may assume that there is an infinite supply of chocolates in the shop Geek visited.
As you know, Geek is a shy person and hence he will enquire about the prices of the chocolates at most 50 times from the shopkeeper. Now, your task is to find the number of chocolates he had enjoyed.
Note: If you call the Shop.get function more than 50 times it will return -1. Price of chocolates are pairwise distinct.
Example 1:
Input:
3 5
2 4 6
Output:
1
Explanation: The prices of chocolates are [2, 4, 6] and Geek had 5 coins with him. So he can only buy chocolate that costs 4 coins (since he always picks the costliest one).
Example 2:
Input:
4 9
1 2 3 4
Output:
3
Explanation: The prices of chocolates are [1, 2, 3, 4] and Geek had 9 coins with him. So he can buy two chocolates that cost 4 coins. Thereafter, he had only 1 coin with him, hence he will have 1 more chocolate (that costs 1 coin).
Your Task:
Return the number of chocolates geeks had eaten. Use the get(int i) function to inquire about the price of the i'th chocolate.
Note that, you can only call that function 50 times after which it will return -1. Test cases are generated such that the answer can always be found.
Expected Time Complexity: O(logN)
Expected Auxiliary Space: O(logN)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/59dfb26eb6c659e6e5f60869ac335f450f97165a/1
Powered by hirist.com
"Shy Geek"
Solve the problem to win points
Geek went to buy some chocolates from a nearby shop with k coins in his pocket. He found that the shop contains n chocolates which are arranged in sorted order (increasing) of their prices.
Now geek wants to taste costlier chocolates so he decided that he will buy the costliest chocolate (of course among the ones that he can afford) till there exists at least one type of chocolate he can afford. You may assume that there is an infinite supply of chocolates in the shop Geek visited.
As you know, Geek is a shy person and hence he will enquire about the prices of the chocolates at most 50 times from the shopkeeper. Now, your task is to find the number of chocolates he had enjoyed.
Note: If you call the Shop.get function more than 50 times it will return -1. Price of chocolates are pairwise distinct.
Example 1:
Input:
3 5
2 4 6
Output:
1
Explanation: The prices of chocolates are [2, 4, 6] and Geek had 5 coins with him. So he can only buy chocolate that costs 4 coins (since he always picks the costliest one).
Example 2:
Input:
4 9
1 2 3 4
Output:
3
Explanation: The prices of chocolates are [1, 2, 3, 4] and Geek had 9 coins with him. So he can buy two chocolates that cost 4 coins. Thereafter, he had only 1 coin with him, hence he will have 1 more chocolate (that costs 1 coin).
Your Task:
Return the number of chocolates geeks had eaten. Use the get(int i) function to inquire about the price of the i'th chocolate.
Note that, you can only call that function 50 times after which it will return -1. Test cases are generated such that the answer can always be found.
Expected Time Complexity: O(logN)
Expected Auxiliary Space: O(logN)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/59dfb26eb6c659e6e5f60869ac335f450f97165a/1
Powered by hirist.com
practice.geeksforgeeks.org
Shy Geek | Practice | GeeksforGeeks
Geek went to buy some chocolates from a nearby shop with k coins in his pocket. He found that the shop contains n chocolates which are arranged in sorted order (increasing) of their prices.
Now geek wants to taste costlier chocolates so he decided
Now geek wants to taste costlier chocolates so he decided
β€2π2
Must Learn!π‘
βWhere Do You See Yourself in 5 Years?β Simple, yet complicated question.
However, this is a significant question that is asked in interviews.
So, how do you answer it smartly? This article will help you with that. Give it a read.
Link- https://www.geeksforgeeks.org/how-to-answer-where-do-you-see-yourself-in-5-years/?utm_s[β¦]medium=marketingteam_gfgmain&utm_campaign=yourselfin5years
βWhere Do You See Yourself in 5 Years?β Simple, yet complicated question.
However, this is a significant question that is asked in interviews.
So, how do you answer it smartly? This article will help you with that. Give it a read.
Link- https://www.geeksforgeeks.org/how-to-answer-where-do-you-see-yourself-in-5-years/?utm_s[β¦]medium=marketingteam_gfgmain&utm_campaign=yourselfin5years
π1
π¨Job Alertπ¨
Zyapaar is hiring for Senior Java Developer.
Location - Ahmedabad, Gujarat
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/zyapaar-JavaDeveloper
Zyapaar is hiring for Senior Java Developer.
Location - Ahmedabad, Gujarat
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/zyapaar-JavaDeveloper
Problem Of The Day
"Count the Substrings"
Solve the problem to win points
Given a string S. The task is to count the number of substrings which contains equal number of lowercase and uppercase letters.
Example 1:
Input:
S = "gEEk"
Output: 3
Explanation: There are 3 substrings of
the given string which satisfy the
condition. They are "gE", "gEEk" and "Ek".
Example 2:
Input:
S = "WomensDAY"
Output: 4
Explanation: There are 4 substrings of
the given string which satisfy the
condition. They are "Wo", "ensDAY",
"nsDA" and "sD"
Your Task:
The task is to complete the function countSubstring() which takes the string S as input parameter and returns the number of substrings which contains equal number of uppercase and lowercase letters.
Expected Time Complexity: O(N*N)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/839d6ba2c2e4c669ba9d9d9f32ad20118937284e/1
Powered by hirist.com
"Count the Substrings"
Solve the problem to win points
Given a string S. The task is to count the number of substrings which contains equal number of lowercase and uppercase letters.
Example 1:
Input:
S = "gEEk"
Output: 3
Explanation: There are 3 substrings of
the given string which satisfy the
condition. They are "gE", "gEEk" and "Ek".
Example 2:
Input:
S = "WomensDAY"
Output: 4
Explanation: There are 4 substrings of
the given string which satisfy the
condition. They are "Wo", "ensDAY",
"nsDA" and "sD"
Your Task:
The task is to complete the function countSubstring() which takes the string S as input parameter and returns the number of substrings which contains equal number of uppercase and lowercase letters.
Expected Time Complexity: O(N*N)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/839d6ba2c2e4c669ba9d9d9f32ad20118937284e/1
Powered by hirist.com
practice.geeksforgeeks.org
Count the Substrings | Practice | GeeksforGeeks
Given a string S. The task is to count the number of substrings which contains equal number of lowercase and uppercase letters.
Example 1:
Input:
S = "gEEk"
Output: 3
Explanation: There are 3 substrings of
the given s
Example 1:
Input:
S = "gEEk"
Output: 3
Explanation: There are 3 substrings of
the given s
π3
Must Learn!π‘
To quickly create and maintain a strong network, on Linkedin you need to thoroughly investigate LinkedInβs variety of resources.
But, features are always evolving, thus your actions must change.
This article talks about networking on LinkedIn alongside the guidance on dos and don'ts. Give it a read.
Link- https://www.geeksforgeeks.org/how-to-network-on-linkedin-dos-and-donts/?utm_source=tele[β¦]tingteam_gfgmain&utm_campaign=networkonlinkedindosanddonts
To quickly create and maintain a strong network, on Linkedin you need to thoroughly investigate LinkedInβs variety of resources.
But, features are always evolving, thus your actions must change.
This article talks about networking on LinkedIn alongside the guidance on dos and don'ts. Give it a read.
Link- https://www.geeksforgeeks.org/how-to-network-on-linkedin-dos-and-donts/?utm_source=tele[β¦]tingteam_gfgmain&utm_campaign=networkonlinkedindosanddonts
Problem Of The Day
"Minimum Integer"
Solve the problem to win points
You are given an array A of size N. Let us denote S as the sum of all integers present in the array. Among all integers present in the array, find the minimum integer X such that S β€ N*X.
Example 1:
Input:
N = 3,
A = { 1, 3, 2}
Output:
2
Explanation:
Sum of integers in the array is 6.
since 6 β€ 3*2, therefore 2 is the answer.
Example 2:
Input:
N = 1,
A = { 3 }
Output:
3
Explanation:
3 is the only possible answer
Your Task:
The task is to complete the function minimumInteger() which takes an integer N and an integer array A as input parameters and returns the minimum integer which satisfies the condition.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/1ccf56f107bcb24242469ea45c02f852165a2184/1
Powered by hirist.com
"Minimum Integer"
Solve the problem to win points
You are given an array A of size N. Let us denote S as the sum of all integers present in the array. Among all integers present in the array, find the minimum integer X such that S β€ N*X.
Example 1:
Input:
N = 3,
A = { 1, 3, 2}
Output:
2
Explanation:
Sum of integers in the array is 6.
since 6 β€ 3*2, therefore 2 is the answer.
Example 2:
Input:
N = 1,
A = { 3 }
Output:
3
Explanation:
3 is the only possible answer
Your Task:
The task is to complete the function minimumInteger() which takes an integer N and an integer array A as input parameters and returns the minimum integer which satisfies the condition.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/1ccf56f107bcb24242469ea45c02f852165a2184/1
Powered by hirist.com
practice.geeksforgeeks.org
Minimum Integer | Practice | GeeksforGeeks
You are given an array A of size N. Let us denote S as the sum of all integers present in the array. Among all integers present in the array, find the minimum integer X such that S β€ N*X.
Example 1:
Example 1:
This media is not supported in your browser
VIEW IN TELEGRAM
Can't keep calm because the GeeksforGeeks summer carnival is going to begin from 5th April to 9th April.πΊ
Hurry up! And grab your GSC tickets now!!ποΈπ«
Pay INR 4000 and get ticket worth INR 6000!!!π²
Redeem them on your favorite courses.β
Get an added bonus of a live class with Mr. Sandeep Jain. β
Link- http://bit.ly/3M8cIM1
Hurry up! And grab your GSC tickets now!!ποΈπ«
Pay INR 4000 and get ticket worth INR 6000!!!π²
Redeem them on your favorite courses.β
Get an added bonus of a live class with Mr. Sandeep Jain. β
Link- http://bit.ly/3M8cIM1
Must Learn!π‘
Confused about deciding what work to start your day with? Then itβs time to eat the frog. Sounds weird?
Don't worry! Eat the frog is a time management strategy based on the notion that tackling an unpleasant or challenging task first thing in the morning gives you a feeling of accomplishment and helps to propel you through subsequent tasks.
This article will help you tackle with the habit of procrastinating with the mentioned technique. Give it a read.
Link- https://www.geeksforgeeks.org/eat-the-frog-how-to-boost-productivity/?utm_source=Telegram&utm_medium=marketingteam_gfgmain&utm_campaign=eat-the-frog-how-to-boost-productivity
Confused about deciding what work to start your day with? Then itβs time to eat the frog. Sounds weird?
Don't worry! Eat the frog is a time management strategy based on the notion that tackling an unpleasant or challenging task first thing in the morning gives you a feeling of accomplishment and helps to propel you through subsequent tasks.
This article will help you tackle with the habit of procrastinating with the mentioned technique. Give it a read.
Link- https://www.geeksforgeeks.org/eat-the-frog-how-to-boost-productivity/?utm_source=Telegram&utm_medium=marketingteam_gfgmain&utm_campaign=eat-the-frog-how-to-boost-productivity
Problem Of The Day
"Even Swap"
Solve the problem to win points
You are given an array a and you need to generate an array b. You are allowed to apply only one type of operation on the array a, any number of times. In one operation you can swap ai, ai+1 if ai+ai+1 is even.
Array b should be generated after applying the above operation any number of times on array a and array b should be lexicographically the largest among all arrays that can be generated from array a, after applying the above operation any number of times.
Example 1:
Input:
N=3
a[]={1,3,5}
Output:
5,3,1
Explanation: [1,3,5],[1,5,3],[3,1,5],[3,5,1],
[5,1,3] and [5,3,1] are all possible
values of array b while the last one is
lexicographically largest.
Example 2:
Input:
N=4
a[]={1,3,4,2}
Output:
b[]={3,1,4,2}
Explanation: [1,3,4,2],[1,3,2,4],[3,1,2,4] and
[3,1,4,2] are all possible values of b among
which the last one is lexicographically largest one.
Your Task:
You don't need to read input or print anything. Your task is to complete the function lexicographically Largest() which takes the array arr[], and its size N as input parameters and returns the array b.
Expected Time Complexity: O(NlogN)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/even-swap/1
Powered by hirist.com
"Even Swap"
Solve the problem to win points
You are given an array a and you need to generate an array b. You are allowed to apply only one type of operation on the array a, any number of times. In one operation you can swap ai, ai+1 if ai+ai+1 is even.
Array b should be generated after applying the above operation any number of times on array a and array b should be lexicographically the largest among all arrays that can be generated from array a, after applying the above operation any number of times.
Example 1:
Input:
N=3
a[]={1,3,5}
Output:
5,3,1
Explanation: [1,3,5],[1,5,3],[3,1,5],[3,5,1],
[5,1,3] and [5,3,1] are all possible
values of array b while the last one is
lexicographically largest.
Example 2:
Input:
N=4
a[]={1,3,4,2}
Output:
b[]={3,1,4,2}
Explanation: [1,3,4,2],[1,3,2,4],[3,1,2,4] and
[3,1,4,2] are all possible values of b among
which the last one is lexicographically largest one.
Your Task:
You don't need to read input or print anything. Your task is to complete the function lexicographically Largest() which takes the array arr[], and its size N as input parameters and returns the array b.
Expected Time Complexity: O(NlogN)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/even-swap/1
Powered by hirist.com
practice.geeksforgeeks.org
Even Swap | Practice | GeeksforGeeks
You are given an array a and you need to generate an array b. You are allowed to apply only one type of operation on the array a, any number of times. In one operation you can swap ai, ai+1 if ai+ai+1 is even.
Array b should be generated a
Array b should be generated a
β€1
This media is not supported in your browser
VIEW IN TELEGRAM
GeeksforGeeks Summer Carnival is coming!!!!
from 5th to 9th April
Grab your GSC tickets now!! ποΈπ«
Pay INR 7500 and get ticket worth INR 11,000!!π²
πRedeem them on your favorite courses.β
πGet an added bonus of a live class with Mr. Sandeep Jain.β
πEXCLUSIVE GfG T-shirt ππβ
Link- http://bit.ly/3nxUhWO
from 5th to 9th April
Grab your GSC tickets now!! ποΈπ«
Pay INR 7500 and get ticket worth INR 11,000!!π²
πRedeem them on your favorite courses.β
πGet an added bonus of a live class with Mr. Sandeep Jain.β
πEXCLUSIVE GfG T-shirt ππβ
Link- http://bit.ly/3nxUhWO
Must Learn!π‘
The journey of your learning starts with a quest that which section of the IT sector you are targeting to get placed.
However, the question that bothers most of the candidates is how much coding is required for placements.
This article will solve the issue and step by step it'll provide answers to all questions. Give it a read.
Link- https://www.geeksforgeeks.org/how-much-coding-is-required-for-placements/?utm_source=te[β¦]in&utm_campaign=how-much-coding-is-required-for-placements
The journey of your learning starts with a quest that which section of the IT sector you are targeting to get placed.
However, the question that bothers most of the candidates is how much coding is required for placements.
This article will solve the issue and step by step it'll provide answers to all questions. Give it a read.
Link- https://www.geeksforgeeks.org/how-much-coding-is-required-for-placements/?utm_source=te[β¦]in&utm_campaign=how-much-coding-is-required-for-placements
Problem Of The Day
"Make Array Elements Equal"
Solve the problem to win points
You are given an integer N. Consider an array arr having N elements where arr[i] = 2*i+1. (The array is 0-indexed)
You are allowed to perform the given operation on the array any number of times:
1) Select two indices i and j and increase arr[i] by 1 and decrease arr[j] by 1.
Your task is to find the minimum number of such operations required to make all the elements of the array equal.
Example 1:
Input:
N = 3
Output:
2
Explanation:
Initially the array is {1, 3, 5}. If we perform
the operation once on the indices 0 and 2, the
resulting array will be {2, 3, 4}. If we again
perform the operation once on the indices 0
and 2, the resulting array will be {3, 3, 3}.
Hence, the minimum operations required is 2
in this case.
Example 2:
Input:
N = 2
Output:
1
Explanation:
The array initially is {1, 3}. After performing
an operation the array will be {2, 2}. Hence,
the answer is 1 in this case.
Your Task:
Complete the function minOperations() which takes the integer N as the input parameter, and returns the minimum operations required to make all the array elements equal.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/1f05c7c12b1084f270c57566b2110967c046730d/1
Powered by hirist.com
"Make Array Elements Equal"
Solve the problem to win points
You are given an integer N. Consider an array arr having N elements where arr[i] = 2*i+1. (The array is 0-indexed)
You are allowed to perform the given operation on the array any number of times:
1) Select two indices i and j and increase arr[i] by 1 and decrease arr[j] by 1.
Your task is to find the minimum number of such operations required to make all the elements of the array equal.
Example 1:
Input:
N = 3
Output:
2
Explanation:
Initially the array is {1, 3, 5}. If we perform
the operation once on the indices 0 and 2, the
resulting array will be {2, 3, 4}. If we again
perform the operation once on the indices 0
and 2, the resulting array will be {3, 3, 3}.
Hence, the minimum operations required is 2
in this case.
Example 2:
Input:
N = 2
Output:
1
Explanation:
The array initially is {1, 3}. After performing
an operation the array will be {2, 2}. Hence,
the answer is 1 in this case.
Your Task:
Complete the function minOperations() which takes the integer N as the input parameter, and returns the minimum operations required to make all the array elements equal.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/1f05c7c12b1084f270c57566b2110967c046730d/1
Powered by hirist.com
practice.geeksforgeeks.org
Make Array Elements Equal | Practice | GeeksforGeeks
You are given an integer N. Consider an array arr having N elements where arr[i] = 2*i+1. (The array is 0-indexed)
You are allowed to perform the given operation on the array any number of times:
1) Select two indices i and j and increase
You are allowed to perform the given operation on the array any number of times:
1) Select two indices i and j and increase
π3
Must Learn!π‘
Linux is a famous operating system that looks complicated at first, but there are a few ways to master it.
As a Linux geek, you can get your hands on the projects to develop your skills at their best.
So, in this article, we will list the 10 best Linux project ideas and improve your skill set.
Link- https://www.geeksforgeeks.org/linux-project-ideas-for-beginners/?utm_source=telegram&ut[β¦]eam_gfgmain&utm_campaign=linux-project-ideas-for-beginners
Linux is a famous operating system that looks complicated at first, but there are a few ways to master it.
As a Linux geek, you can get your hands on the projects to develop your skills at their best.
So, in this article, we will list the 10 best Linux project ideas and improve your skill set.
Link- https://www.geeksforgeeks.org/linux-project-ideas-for-beginners/?utm_source=telegram&ut[β¦]eam_gfgmain&utm_campaign=linux-project-ideas-for-beginners
π¨Job Alert π¨
Omnify, Inc is hiring for PHP Laravel Intern.
Location - Bangalore
Experience - Intern
Apply by - Mar 31, 2023
Apply via the following link and share the opportunity with your friends- https://practice.geeksforgeeks.org/jobs/omnify-php-laravel-interns?utm_source=telegram&utm[β¦]ingteam_gfgmain&utm_campaign=omnify-php-laravel-interns
Omnify, Inc is hiring for PHP Laravel Intern.
Location - Bangalore
Experience - Intern
Apply by - Mar 31, 2023
Apply via the following link and share the opportunity with your friends- https://practice.geeksforgeeks.org/jobs/omnify-php-laravel-interns?utm_source=telegram&utm[β¦]ingteam_gfgmain&utm_campaign=omnify-php-laravel-interns
Problem Of The Day
"Make Array Elements Equal"
Solve the problem to win points
Knight is at (start_x,start_y) in Geekland which is represented by an NxM 2D matrix.
Each cell in the matrix contains some points. In the ith step, the knight can collect all the points from all the cells that can be visited in exactly i steps without revisiting any cell.
Also, the knight has some magical powers that enable him to fetch coins from the future i.e. If the knight can collect y coins in the xth step he can fetch all the coins that he will collect in the (x + y)th step and if the knight can collect z coins in the yth step he can fetch all the coins that he will collect in the (y + z)th step and so on without increasing the step count i.e. knight will stay on xth step and will get all the coins of the future steps mentioned above((x + y)th step coins + (y+z)th steps + ...).
Find the minimum number of steps required to collect the maximum points.
Note: The knight moves exactly the same as the knight on a chess board. Please follow 0 indexing.
Example 1:
Input:
n = 9
m = 10
start_x = 4, start_y = 5
arr =
0 0 0 2 0 2 0 2 0 0
0 0 2 0 2 0 2 0 2 0
0 2 0 0 1 2 0 0 0 2
0 0 2 0 2 0 2 0 2 0
0 2 0 2 0 0 0 2 0 2
0 0 2 0 2 0 2 0 2 0
0 2 0 0 0 2 0 0 0 2
0 0 2 0 2 0 2 0 2 0
0 0 0 2 0 2 0 2 0 0
Output: 1
Explanation: minimum knight have to take 1 steps to gain maximum points.
Initially, the knight has 0 coins, he will take 1 step to collect 1 point (sum of cells denoted in red color).
Now in the second step, he can collect points from all the cells colored green i.e. 64 points.
But with his magical power, at the 1st step, he can fetch points from the (1 + 1)th step. Therefore he can collect 1 + 64 coins at step 1 only. Hence answer is 1.
Example 2:
Input:
n = 3
m = 3
start_x = 2, start_y = 1
arr =
7 6 8
9 1 4
6 2 8
Output:0
Explanation:
Initially, the knight has 2 points, or more formally we can say that at the 0th step knight has 2 points.
In the first step, he can collect points from cells (0, 0) and (0, 2) i.e. 15 points.
In the second step, he can collect points from cells (1, 0) and (1, 2) i.e. 13 coins.
In the third step, he can collect points from cells (2, 0) and (2, 2) i.e. 14 points.
In the fourth step, he can collect points from the cell (0, 1) i.e. 6 points.
So in each step, he can collect coins like -You can see in the below image Knight can collect 15 coins in the 0th step only
Your Task:
You don't need to read input or print anything. Your task is to complete the function knightInGeekland() which takes 2-d array arr[][], starting coordinates of knight start_x, and start_y as input, and return an integer value as min steps to gain max points.
Expected Time Complexity: O(N*M)
Expected Auxiliary Space: O(N*M)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/7e5ec07f9d865297cff9a91522c2ce805433b420/1
Powered by hirist.com
"Make Array Elements Equal"
Solve the problem to win points
Knight is at (start_x,start_y) in Geekland which is represented by an NxM 2D matrix.
Each cell in the matrix contains some points. In the ith step, the knight can collect all the points from all the cells that can be visited in exactly i steps without revisiting any cell.
Also, the knight has some magical powers that enable him to fetch coins from the future i.e. If the knight can collect y coins in the xth step he can fetch all the coins that he will collect in the (x + y)th step and if the knight can collect z coins in the yth step he can fetch all the coins that he will collect in the (y + z)th step and so on without increasing the step count i.e. knight will stay on xth step and will get all the coins of the future steps mentioned above((x + y)th step coins + (y+z)th steps + ...).
Find the minimum number of steps required to collect the maximum points.
Note: The knight moves exactly the same as the knight on a chess board. Please follow 0 indexing.
Example 1:
Input:
n = 9
m = 10
start_x = 4, start_y = 5
arr =
0 0 0 2 0 2 0 2 0 0
0 0 2 0 2 0 2 0 2 0
0 2 0 0 1 2 0 0 0 2
0 0 2 0 2 0 2 0 2 0
0 2 0 2 0 0 0 2 0 2
0 0 2 0 2 0 2 0 2 0
0 2 0 0 0 2 0 0 0 2
0 0 2 0 2 0 2 0 2 0
0 0 0 2 0 2 0 2 0 0
Output: 1
Explanation: minimum knight have to take 1 steps to gain maximum points.
Initially, the knight has 0 coins, he will take 1 step to collect 1 point (sum of cells denoted in red color).
Now in the second step, he can collect points from all the cells colored green i.e. 64 points.
But with his magical power, at the 1st step, he can fetch points from the (1 + 1)th step. Therefore he can collect 1 + 64 coins at step 1 only. Hence answer is 1.
Example 2:
Input:
n = 3
m = 3
start_x = 2, start_y = 1
arr =
7 6 8
9 1 4
6 2 8
Output:0
Explanation:
Initially, the knight has 2 points, or more formally we can say that at the 0th step knight has 2 points.
In the first step, he can collect points from cells (0, 0) and (0, 2) i.e. 15 points.
In the second step, he can collect points from cells (1, 0) and (1, 2) i.e. 13 coins.
In the third step, he can collect points from cells (2, 0) and (2, 2) i.e. 14 points.
In the fourth step, he can collect points from the cell (0, 1) i.e. 6 points.
So in each step, he can collect coins like -You can see in the below image Knight can collect 15 coins in the 0th step only
Your Task:
You don't need to read input or print anything. Your task is to complete the function knightInGeekland() which takes 2-d array arr[][], starting coordinates of knight start_x, and start_y as input, and return an integer value as min steps to gain max points.
Expected Time Complexity: O(N*M)
Expected Auxiliary Space: O(N*M)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/7e5ec07f9d865297cff9a91522c2ce805433b420/1
Powered by hirist.com
practice.geeksforgeeks.org
Knight in Geekland | Practice | GeeksforGeeks
Knight is at (start_x,start_y) in Geekland which is represented by an NxM 2D matrix.Each cell in the matrix contains some points. In the ith step, the knight can collect all the points from all the cells that can be visited in exactly i steps without
π5
Learn more!π‘
The best social network for seeking new career chances is without a mistake LinkedIn.
If you have a strong network, you can use Linkedin to find anything youβre looking for, from a job to a partnership to just a freelancer.
In this article, weβll uncover how to write a LinkedIn recommendation that will win you plus points from recruiters. Give it a read.
Link- https://www.geeksforgeeks.org/how-to-write-a-linkedin-recommendation-with-examples-and-[β¦]in&utm_campaign=linkedinrecommendationswithexamplesandtips
The best social network for seeking new career chances is without a mistake LinkedIn.
If you have a strong network, you can use Linkedin to find anything youβre looking for, from a job to a partnership to just a freelancer.
In this article, weβll uncover how to write a LinkedIn recommendation that will win you plus points from recruiters. Give it a read.
Link- https://www.geeksforgeeks.org/how-to-write-a-linkedin-recommendation-with-examples-and-[β¦]in&utm_campaign=linkedinrecommendationswithexamplesandtips
π1π©1