๐จJob Alert๐จ
PayPal is hiring for Software Engineer.
Location - Bengaluru, Karnataka
Experience - 3 - 10 Years
Apply by - Aug 20, 2023
Apply via the following link and share the opportunity with your friends- https://www.geeksforgeeks.org/jobs/paypal-ext-softwareengineer?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
PayPal is hiring for Software Engineer.
Location - Bengaluru, Karnataka
Experience - 3 - 10 Years
Apply by - Aug 20, 2023
Apply via the following link and share the opportunity with your friends- https://www.geeksforgeeks.org/jobs/paypal-ext-softwareengineer?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
Problem Of The Day
"Inorder Successor in BST"
Given a BST, and a reference to a Node x in the BST. Find the Inorder Successor of the given node in the BST.
Example 1:
Input:
2
/ \
1 3
K(data of x) = 2
Output: 3
Explanation:
Inorder traversal : 1 2 3
Hence, inorder successor of 2 is 3.
Example 2:
Input:
20
/ \
8 22
/ \
4 12
/ \
10 14
K(data of x) = 8
Output: 10
Explanation:
Inorder traversal: 4 8 10 12 14 20 22
Hence, successor of 8 is 10.
Your Task:
You don't need to read input or print anything. Your task is to complete the function inOrderSuccessor(). This function takes the root node and the reference node as argument and returns the node that is inOrder successor of the reference node. If there is no successor, return null value.
Expected Time Complexity: O(Height of the BST).
Expected Auxiliary Space: O(1).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/inorder-successor-in-bst/1
"Inorder Successor in BST"
Given a BST, and a reference to a Node x in the BST. Find the Inorder Successor of the given node in the BST.
Example 1:
Input:
2
/ \
1 3
K(data of x) = 2
Output: 3
Explanation:
Inorder traversal : 1 2 3
Hence, inorder successor of 2 is 3.
Example 2:
Input:
20
/ \
8 22
/ \
4 12
/ \
10 14
K(data of x) = 8
Output: 10
Explanation:
Inorder traversal: 4 8 10 12 14 20 22
Hence, successor of 8 is 10.
Your Task:
You don't need to read input or print anything. Your task is to complete the function inOrderSuccessor(). This function takes the root node and the reference node as argument and returns the node that is inOrder successor of the reference node. If there is no successor, return null value.
Expected Time Complexity: O(Height of the BST).
Expected Auxiliary Space: O(1).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/inorder-successor-in-bst/1
www.geeksforgeeks.org
Inorder Successor in BST | Practice | GeeksforGeeks
Given a BST, and a reference to a Node x in the BST. Find the Inorder Successor of the given node in the BST.
Example 1:
Input:
2
/ \
1 3
K(data of x) = 2
Output: 3
Explanation:
Inorder traversal : 1 2 3
Hence, i
Example 1:
Input:
2
/ \
1 3
K(data of x) = 2
Output: 3
Explanation:
Inorder traversal : 1 2 3
Hence, i
๐1
Problem Of The Day
"BFS of graph"
Given a directed graph. The task is to do Breadth First Traversal of this graph starting from 0.
Note: One can move from node u to node v only if there's an edge from u to v. Find the BFS traversal of the graph starting from the 0th vertex, from left to right according to the input graph. Also, you should only take nodes directly or indirectly connected from Node 0 in consideration.
Example 1:
Input:
Output: 0 1 2 3 4
Explanation:
0 is connected to 1 , 2 , 3.
2 is connected to 4.
so starting from 0, it will go to 1 then 2
then 3. After this 2 to 4, thus bfs will be
0 1 2 3 4.
Example 2:
Input:
Output: 0 1 2
Explanation:
0 is connected to 1 , 2.
so starting from 0, it will go to 1 then 2,
thus bfs will be 0 1 2.
Your task:
You dont need to read input or print anything. Your task is to complete the function bfsOfGraph() which takes the integer V denoting the number of vertices and adjacency list as input parameters and returns a list containing the BFS traversal of the graph starting from the 0th vertex from left to right.
Expected Time Complexity: O(V + E)
Expected Auxiliary Space: O(V)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/bfs-traversal-of-graph/1
"BFS of graph"
Given a directed graph. The task is to do Breadth First Traversal of this graph starting from 0.
Note: One can move from node u to node v only if there's an edge from u to v. Find the BFS traversal of the graph starting from the 0th vertex, from left to right according to the input graph. Also, you should only take nodes directly or indirectly connected from Node 0 in consideration.
Example 1:
Input:
Output: 0 1 2 3 4
Explanation:
0 is connected to 1 , 2 , 3.
2 is connected to 4.
so starting from 0, it will go to 1 then 2
then 3. After this 2 to 4, thus bfs will be
0 1 2 3 4.
Example 2:
Input:
Output: 0 1 2
Explanation:
0 is connected to 1 , 2.
so starting from 0, it will go to 1 then 2,
thus bfs will be 0 1 2.
Your task:
You dont need to read input or print anything. Your task is to complete the function bfsOfGraph() which takes the integer V denoting the number of vertices and adjacency list as input parameters and returns a list containing the BFS traversal of the graph starting from the 0th vertex from left to right.
Expected Time Complexity: O(V + E)
Expected Auxiliary Space: O(V)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/bfs-traversal-of-graph/1
www.geeksforgeeks.org
BFS of graph | Practice | GeeksforGeeks
Given a connected undirected graph containing V vertices, represented by a 2-d adjacency list adj[][], where each adj[i] represents the list of vertices connected to vertex i. Perform a Breadth First Search (BFS)&nb
โค1๐1
When youโre building a Restful API it is important to design it properly to avoid any bug or issue in your application. You need to take care of the performance, security, and ease of use for API consumers.
It is good to follow some good conventions to build an API that is clean, understandable, and easy to work with.
There are so many aspects you need to consider when youโre building a Restful API in your application. In this article, we will highlight those aspects in detail. Letโs discuss the best coding convention to build the REST API in your application.
Link- https://bit.ly/3OBLQ7J
It is good to follow some good conventions to build an API that is clean, understandable, and easy to work with.
There are so many aspects you need to consider when youโre building a Restful API in your application. In this article, we will highlight those aspects in detail. Letโs discuss the best coding convention to build the REST API in your application.
Link- https://bit.ly/3OBLQ7J
๐3
Problem Of The Day
"DFS of Graph"
You are given a connected undirected graph. Perform a Depth First Traversal of the graph.
Note: Use a recursive approach to find the DFS traversal of the graph starting from the 0th vertex from left to right according to the graph.
Example 1:
Input: V = 5 , adj = [[2,3,1] , [0], [0,4], [0], [2]]
Output: 0 2 4 3 1
Explanation:
0 is connected to 2, 3, 1.
1 is connected to 0.
2 is connected to 0 and 4.
3 is connected to 0.
4 is connected to 2.
so starting from 0, it will go to 2 then 4,
and then 3 and 1.
Thus dfs will be 0 2 4 3 1.
Example 2:
Input: V = 4, adj = [[1,3], [2,0], [1], [0]]
Output: 0 1 2 3
Explanation:
0 is connected to 1 , 3.
1 is connected to 0, 2.
2 is connected to 1.
3 is connected to 0.
so starting from 0, it will go to 1 then 2
then back to 0 then 0 to 3
thus dfs will be 0 1 2 3.
Your task:
You don't need to read input or print anything. Your task is to complete the function dfsOfGraph() which takes the integer V denoting the number of vertices and adjacency list as input parameters and returns a list containing the DFS traversal of the graph starting from the 0th vertex from left to right according to the graph.
Expected Time Complexity: O(V + E)
Expected Auxiliary Space: O(V)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/depth-first-traversal-for-a-graph/1
"DFS of Graph"
You are given a connected undirected graph. Perform a Depth First Traversal of the graph.
Note: Use a recursive approach to find the DFS traversal of the graph starting from the 0th vertex from left to right according to the graph.
Example 1:
Input: V = 5 , adj = [[2,3,1] , [0], [0,4], [0], [2]]
Output: 0 2 4 3 1
Explanation:
0 is connected to 2, 3, 1.
1 is connected to 0.
2 is connected to 0 and 4.
3 is connected to 0.
4 is connected to 2.
so starting from 0, it will go to 2 then 4,
and then 3 and 1.
Thus dfs will be 0 2 4 3 1.
Example 2:
Input: V = 4, adj = [[1,3], [2,0], [1], [0]]
Output: 0 1 2 3
Explanation:
0 is connected to 1 , 3.
1 is connected to 0, 2.
2 is connected to 1.
3 is connected to 0.
so starting from 0, it will go to 1 then 2
then back to 0 then 0 to 3
thus dfs will be 0 1 2 3.
Your task:
You don't need to read input or print anything. Your task is to complete the function dfsOfGraph() which takes the integer V denoting the number of vertices and adjacency list as input parameters and returns a list containing the DFS traversal of the graph starting from the 0th vertex from left to right according to the graph.
Expected Time Complexity: O(V + E)
Expected Auxiliary Space: O(V)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/depth-first-traversal-for-a-graph/1
www.geeksforgeeks.org
DFS of Graph | Practice | GeeksforGeeks
Given a connected undirected graph containing V vertices represented by a 2-d adjacency list adj[][], where each adj[i] represents the list of vertices connected to vertex i. Perform a Depth First Search (DFS) traversal starting f
๐1
Must Learn!๐ก
Software Design Patternsโฆ Software design pattern is a general, reusable solution to a commonly occurring problem within a given context in software design.
Design patterns are common vocabulary for developers to talk about software solutions. When you (as a developer) say โWe should implement this using the singleton patternโ all the other developers clearly understand that whatโs the common point of reference.
Link- https://bit.ly/3rYowIn
Software Design Patternsโฆ Software design pattern is a general, reusable solution to a commonly occurring problem within a given context in software design.
Design patterns are common vocabulary for developers to talk about software solutions. When you (as a developer) say โWe should implement this using the singleton patternโ all the other developers clearly understand that whatโs the common point of reference.
Link- https://bit.ly/3rYowIn
๐1
๐จJob Alert๐จ
IBM is hiring for Fullstack Developer.
Location - Kochi, Kerala, India (On-site)
Experience - 9 - 12 Years
Apply by - Aug 20, 2023
Apply via the following link and share the opportunity with your friends- https://www.geeksforgeeks.org/jobs/ibm-fullstack-developer?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
IBM is hiring for Fullstack Developer.
Location - Kochi, Kerala, India (On-site)
Experience - 9 - 12 Years
Apply by - Aug 20, 2023
Apply via the following link and share the opportunity with your friends- https://www.geeksforgeeks.org/jobs/ibm-fullstack-developer?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
Problem Of The Day
"Shortest Source to Destination Path"
Given a 2D binary matrix A(0-based index) of dimensions NxM. Find the minimum number of steps required to reach from (0,0) to (X, Y).
Note: You can only move left, right, up and down, and only through cells that contain 1.
Example 1:
Input:
N=3, M=4
A=[[1,0,0,0],
[1,1,0,1],
[0,1,1,1]]
X=2, Y=3
Output:
5
Explanation:
The shortest path is as follows:
(0,0)->(1,0)->(1,1)->(2,1)->(2,2)->(2,3).
Example 2:
Input:
N=3, M=4
A=[[1,1,1,1],
[0,0,0,1],
[0,0,0,1]]
X=0, Y=3
Output:
3
Explanation:
The shortest path is as follows:
(0,0)->(0,1)->(0,2)->(0,3).
Your Task:
You don't need to read input or print anything. Your task is to complete the function shortestDistance() which takes the integer N, M, X, Y, and the 2D binary matrix A as input parameters and returns the minimum number of steps required to go from (0,0) to (X, Y).If it is impossible to go from (0,0) to (X, Y),then function returns -1. If value of the cell (0,0) is 0 (i.e A[0][0]=0) then return -1.
Expected Time Complexity:O(N*M)
Expected Auxillary Space:O(N*M)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/shortest-source-to-destination-path3544/1
"Shortest Source to Destination Path"
Given a 2D binary matrix A(0-based index) of dimensions NxM. Find the minimum number of steps required to reach from (0,0) to (X, Y).
Note: You can only move left, right, up and down, and only through cells that contain 1.
Example 1:
Input:
N=3, M=4
A=[[1,0,0,0],
[1,1,0,1],
[0,1,1,1]]
X=2, Y=3
Output:
5
Explanation:
The shortest path is as follows:
(0,0)->(1,0)->(1,1)->(2,1)->(2,2)->(2,3).
Example 2:
Input:
N=3, M=4
A=[[1,1,1,1],
[0,0,0,1],
[0,0,0,1]]
X=0, Y=3
Output:
3
Explanation:
The shortest path is as follows:
(0,0)->(0,1)->(0,2)->(0,3).
Your Task:
You don't need to read input or print anything. Your task is to complete the function shortestDistance() which takes the integer N, M, X, Y, and the 2D binary matrix A as input parameters and returns the minimum number of steps required to go from (0,0) to (X, Y).If it is impossible to go from (0,0) to (X, Y),then function returns -1. If value of the cell (0,0) is 0 (i.e A[0][0]=0) then return -1.
Expected Time Complexity:O(N*M)
Expected Auxillary Space:O(N*M)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/shortest-source-to-destination-path3544/1
www.geeksforgeeks.org
Shortest Source to Destination Path | Practice | GeeksforGeeks
Given a 2D binary matrix A(0-based index) of dimensions NxM. Find the minimum number of steps required to reach from (0,0) to (X, Y).Note: You can only move left, right, up and down, and only through cells that contain 1.
Example 1:
Input:
N=3,
Example 1:
Input:
N=3,
๐3
Must Learn!๐ก
If youโre also a fan of Linkedin creators like Ankur Warikoo, Kunal Shah, Rachana Ranade, Vaibhav Sisinty, and others and want to be like one, then the first step is to write viral LinkedIn posts that will get you started and put you on the map.
But what if youโre not a writer and more so โ a storyteller that is essential to write viral LinkedIn posts? What to do then?
Here the mighty ChatGPT can help you to write Linkedin posts that can go viral and can bring you good engagement but the secret to getting a virality is โnot trying to get viralโ. Now, letโs get back to where we were โ ChatGPT.
Link- https://bit.ly/44Rs7Xl
If youโre also a fan of Linkedin creators like Ankur Warikoo, Kunal Shah, Rachana Ranade, Vaibhav Sisinty, and others and want to be like one, then the first step is to write viral LinkedIn posts that will get you started and put you on the map.
But what if youโre not a writer and more so โ a storyteller that is essential to write viral LinkedIn posts? What to do then?
Here the mighty ChatGPT can help you to write Linkedin posts that can go viral and can bring you good engagement but the secret to getting a virality is โnot trying to get viralโ. Now, letโs get back to where we were โ ChatGPT.
Link- https://bit.ly/44Rs7Xl
โค1
Problem Of The Day
"Shortest path in Directed Acyclic Graph"
Given a Directed Acyclic Graph of N vertices from 0 to N-1 and a 2D Integer array(or vector) edges[ ][ ] of length M, where there is a directed edge from edge[i][0] to edge[i][1] with a distance of edge[i][2] for all i.
Find the shortest path from src(0) vertex to all the vertices and if it is impossible to reach any vertex, then return -1 for that vertex.
Example1:
Input:
N = 4, M = 2
edge = [[0,1,2],[0,2,1]
Output:
0 2 1 -1
Explanation:
Shortest path from 0 to 1 is 0->1 with edge weight 2.
Shortest path from 0 to 2 is 0->2 with edge weight 1.
There is no way we can reach 3, so it's -1 for 3.
Example2:
Input:
N = 6, M = 7
edge = [[0,1,2],[0,4,1],[4,5,4],[4,2,2],[1,2,3],[2,3,6],[5,3,1]]
Output:
0 2 3 6 1 5
Explanation:
Shortest path from 0 to 1 is 0->1 with edge weight 2.
Shortest path from 0 to 2 is 0->4->2 with edge weight 1+2=3.
Shortest path from 0 to 3 is 0->4->5->3 with edge weight 1+4+1=6.
Shortest path from 0 to 4 is 0->4 with edge weight 1.
Shortest path from 0 to 5 is 0->4->5 with edge weight 1+4=5.
Your Task:
You don't need to print or input anything. Complete the function shortest path() which takes an integer N as number of vertices, an integer M as number of edges and a 2D Integer array(or vector) edges as the input parameters and returns an integer array(or vector), denoting the list of distance from src to all nodes.
Expected Time Complexity: O(N+M), where N is the number of nodes and M is edges
Expected Space Complexity: O(N)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/shortest-path-in-undirected-graph/1
"Shortest path in Directed Acyclic Graph"
Given a Directed Acyclic Graph of N vertices from 0 to N-1 and a 2D Integer array(or vector) edges[ ][ ] of length M, where there is a directed edge from edge[i][0] to edge[i][1] with a distance of edge[i][2] for all i.
Find the shortest path from src(0) vertex to all the vertices and if it is impossible to reach any vertex, then return -1 for that vertex.
Example1:
Input:
N = 4, M = 2
edge = [[0,1,2],[0,2,1]
Output:
0 2 1 -1
Explanation:
Shortest path from 0 to 1 is 0->1 with edge weight 2.
Shortest path from 0 to 2 is 0->2 with edge weight 1.
There is no way we can reach 3, so it's -1 for 3.
Example2:
Input:
N = 6, M = 7
edge = [[0,1,2],[0,4,1],[4,5,4],[4,2,2],[1,2,3],[2,3,6],[5,3,1]]
Output:
0 2 3 6 1 5
Explanation:
Shortest path from 0 to 1 is 0->1 with edge weight 2.
Shortest path from 0 to 2 is 0->4->2 with edge weight 1+2=3.
Shortest path from 0 to 3 is 0->4->5->3 with edge weight 1+4+1=6.
Shortest path from 0 to 4 is 0->4 with edge weight 1.
Shortest path from 0 to 5 is 0->4->5 with edge weight 1+4=5.
Your Task:
You don't need to print or input anything. Complete the function shortest path() which takes an integer N as number of vertices, an integer M as number of edges and a 2D Integer array(or vector) edges as the input parameters and returns an integer array(or vector), denoting the list of distance from src to all nodes.
Expected Time Complexity: O(N+M), where N is the number of nodes and M is edges
Expected Space Complexity: O(N)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/shortest-path-in-undirected-graph/1
www.geeksforgeeks.org
Shortest path in Directed Acyclic Graph | Practice | GeeksforGeeks
Given a Directed Acyclic Graph of N vertices from 0 to N-1 and a 2D Integer array(or vector) edges[ ][ ] of length M, where there is a directed edge from edge[i][0] to edge[i][1] with a distance of edge[i][2] for all i.
Find the shortest path from sr
Find the shortest path from sr
๐1
Must Learn!๐ก
You might have used various commands in gitโฆ.git add, git push, git pull, git commit, etc but if we ask how things work behind the scene and how the flow of Git looks like then what would be your answerโฆ
Most of us know donโt knowโฆ
Today in this blog we are going to explore this amazing tool a bit more. We will discuss in-depth how Git works internally.
Link- https://bit.ly/43R42Pi
You might have used various commands in gitโฆ.git add, git push, git pull, git commit, etc but if we ask how things work behind the scene and how the flow of Git looks like then what would be your answerโฆ
Most of us know donโt knowโฆ
Today in this blog we are going to explore this amazing tool a bit more. We will discuss in-depth how Git works internally.
Link- https://bit.ly/43R42Pi
๐1
๐จJob Alert๐จ
Futurelens Technology is hiring for Flutter Developer.
Location - Surat, Gujarat
Experience - 0.5 - 3 Years
Apply by - Sep 02, 2023
Apply via the following link and share the opportunity with your friends- https://www.geeksforgeeks.org/jobs/futurelenstechnology-flutter-developer?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
Futurelens Technology is hiring for Flutter Developer.
Location - Surat, Gujarat
Experience - 0.5 - 3 Years
Apply by - Sep 02, 2023
Apply via the following link and share the opportunity with your friends- https://www.geeksforgeeks.org/jobs/futurelenstechnology-flutter-developer?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
Problem Of The Day
"Reverse a Stack"
You are given a stack St. You have to reverse the stack using recursion.
Example 1:
Input:
St = {3,2,1,7,6}
Output:
{6,7,1,2,3}
Explanation:
Input stack after reversing will look like the stack in the output.
Example 2:
Input:
St = {4,3,9,6}
Output:
{6,9,3,4}
Explanation:
Input stack after reversing will look like the stack in the output.
Your Task:
You don't need to read input or print anything. Your task is to complete the function Reverse() which takes the stack St as input and reverses the given stack.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/reverse-a-stack/1
"Reverse a Stack"
You are given a stack St. You have to reverse the stack using recursion.
Example 1:
Input:
St = {3,2,1,7,6}
Output:
{6,7,1,2,3}
Explanation:
Input stack after reversing will look like the stack in the output.
Example 2:
Input:
St = {4,3,9,6}
Output:
{6,9,3,4}
Explanation:
Input stack after reversing will look like the stack in the output.
Your Task:
You don't need to read input or print anything. Your task is to complete the function Reverse() which takes the stack St as input and reverses the given stack.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/reverse-a-stack/1
practice.geeksforgeeks.org
Reverse a Stack | Practice | GeeksforGeeks
You are given a stack St. You have to reverse the stack using recursion.
Example 1:
Input:
St = {3,2,1,7,6}
Output:
{6,7,1,2,3}Explanation:Input stack after reversing will look like the stack in the output.
Example 2:
Input:
St = {4,3,9,6}
Output:
{6
Example 1:
Input:
St = {3,2,1,7,6}
Output:
{6,7,1,2,3}Explanation:Input stack after reversing will look like the stack in the output.
Example 2:
Input:
St = {4,3,9,6}
Output:
{6
๐2
Must Learn!๐ก
Instagram users will now be able to share a 30-second song clip as an additional means of expression in their Instagram Notes, which previously could only contain text and emoticons.
The new Music Notes are expected to be used by users to express their sentiments, moods, or simply what music theyโve been listening to lately.
Users can choose to express their comments in addition to the shared footage by adding a caption to a Music Note.
Link- https://bit.ly/47m7Rib
Instagram users will now be able to share a 30-second song clip as an additional means of expression in their Instagram Notes, which previously could only contain text and emoticons.
The new Music Notes are expected to be used by users to express their sentiments, moods, or simply what music theyโve been listening to lately.
Users can choose to express their comments in addition to the shared footage by adding a caption to a Music Note.
Link- https://bit.ly/47m7Rib
We are back with the 114th edition of GFG Weekly Coding Contest.๐
Shine bright and be a proficient coder with us.๐
Register now - https://bit.ly/3Oghark
Shine bright and be a proficient coder with us.๐
Register now - https://bit.ly/3Oghark
Problem Of The Day
"Chocolate Distribution Problem"
Given an array A[ ] of positive integers of size N, where each value represents the number of chocolates in a packet. Each packet can have a variable number of chocolates. There are M students, the task is to distribute chocolate packets among M students such that :
1. Each student gets exactly one packet.
2. The difference between maximum number of chocolates given to a student and minimum number of chocolates given to a student is minimum.
Example 1:
Input:
N = 8, M = 5
A = {3, 4, 1, 9, 56, 7, 9, 12}
Output: 6
Explanation: The minimum difference between maximum chocolates and minimum chocolates is 9 - 3 = 6 by choosing following M packets :{3, 4, 9, 7, 9}.
Example 2:
Input:
N = 7, M = 3
A = {7, 3, 2, 4, 9, 12, 56}
Output: 2
Explanation: The minimum difference between maximum chocolates and minimum chocolates is 4 - 2 = 2 by choosing following M packets :{3, 2, 4}.
Your Task:
You don't need to take any input or print anything. Your task is to complete the function findMinDiff() which takes array A[ ], N and M as input parameters and returns the minimum possible difference between maximum number of chocolates given to a student and minimum number of chocolates given to a student.
Expected Time Complexity: O(N*Log(N))
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/chocolate-distribution-problem3825/1
"Chocolate Distribution Problem"
Given an array A[ ] of positive integers of size N, where each value represents the number of chocolates in a packet. Each packet can have a variable number of chocolates. There are M students, the task is to distribute chocolate packets among M students such that :
1. Each student gets exactly one packet.
2. The difference between maximum number of chocolates given to a student and minimum number of chocolates given to a student is minimum.
Example 1:
Input:
N = 8, M = 5
A = {3, 4, 1, 9, 56, 7, 9, 12}
Output: 6
Explanation: The minimum difference between maximum chocolates and minimum chocolates is 9 - 3 = 6 by choosing following M packets :{3, 4, 9, 7, 9}.
Example 2:
Input:
N = 7, M = 3
A = {7, 3, 2, 4, 9, 12, 56}
Output: 2
Explanation: The minimum difference between maximum chocolates and minimum chocolates is 4 - 2 = 2 by choosing following M packets :{3, 2, 4}.
Your Task:
You don't need to take any input or print anything. Your task is to complete the function findMinDiff() which takes array A[ ], N and M as input parameters and returns the minimum possible difference between maximum number of chocolates given to a student and minimum number of chocolates given to a student.
Expected Time Complexity: O(N*Log(N))
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/chocolate-distribution-problem3825/1
www.geeksforgeeks.org
Chocolate Distribution Problem | Practice | GeeksforGeeks
Given an array A[ ] of positive integers of size N, where each value represents the number of chocolates in a packet. Each packet can have a variable number of chocolates. There are M students, the task is to distribute chocolate packets among M stud
๐1
Must Learn!
The significance of internships and placements in the professional development of students is underscored by the knowledge and exposure they offer to an organization. The project work that the students receive as part of these programs is a vital aspect.
A good information technology project can set you apart from the competition and improve your chances of landing the employment opportunity of your dreams.
Letโs talk about how to create quality tech projects for internships and job placement.
Link- https://www.geeksforgeeks.org/how-to-make-good-projects-for-internships-and-placements/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
The significance of internships and placements in the professional development of students is underscored by the knowledge and exposure they offer to an organization. The project work that the students receive as part of these programs is a vital aspect.
A good information technology project can set you apart from the competition and improve your chances of landing the employment opportunity of your dreams.
Letโs talk about how to create quality tech projects for internships and job placement.
Link- https://www.geeksforgeeks.org/how-to-make-good-projects-for-internships-and-placements/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
๐3
Get Hired with Fun!
We get talent, you get placed...Deal done!๐ค
GeeksforGeeks is looking for a Technical Content Engineer. Now, the rule is very simple.
Register for the Hack-a-Thon and participate. Hurry up!
Link - https://practice.geeksforgeeks.org/hackathon/geeksforgeeks-hiring-data-science
We get talent, you get placed...Deal done!๐ค
GeeksforGeeks is looking for a Technical Content Engineer. Now, the rule is very simple.
Register for the Hack-a-Thon and participate. Hurry up!
Link - https://practice.geeksforgeeks.org/hackathon/geeksforgeeks-hiring-data-science
๐2๐2
Problem Of The Day
"String Permutations"
Given a string S. The task is to find all permutations (need not be different) of a given string.
Example 1:
Input:
S = AAA
Output: AAA AAA AAA AAA AAA AAA
Explanation: There are total 6 permutations, as given in the output.
Example 2:
Input:
S = ABSG
Output: ABGS ABSG AGBS AGSB ASBG ASGB
BAGS BASG BGAS BGSA BSAG BSGA GABS
GASB GBAS GBSA GSAB GSBA SABG SAGB
SBAG SBGA SGAB SGBA
Explanation: There are total 24 permutations, as given in the output.
Your Task:
This is a function problem. You only need to complete the function permutation that takes S as parameter and returns the list of permutations in lexicographically increasing order. The newline is automatically added by driver code.
Constraints:
1 โค size of string โค 5
Expected Time Complexity: O(N * N!), N = length of string.
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/permutations-of-a-given-string-1587115620/1
"String Permutations"
Given a string S. The task is to find all permutations (need not be different) of a given string.
Example 1:
Input:
S = AAA
Output: AAA AAA AAA AAA AAA AAA
Explanation: There are total 6 permutations, as given in the output.
Example 2:
Input:
S = ABSG
Output: ABGS ABSG AGBS AGSB ASBG ASGB
BAGS BASG BGAS BGSA BSAG BSGA GABS
GASB GBAS GBSA GSAB GSBA SABG SAGB
SBAG SBGA SGAB SGBA
Explanation: There are total 24 permutations, as given in the output.
Your Task:
This is a function problem. You only need to complete the function permutation that takes S as parameter and returns the list of permutations in lexicographically increasing order. The newline is automatically added by driver code.
Constraints:
1 โค size of string โค 5
Expected Time Complexity: O(N * N!), N = length of string.
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/permutations-of-a-given-string-1587115620/1
practice.geeksforgeeks.org
String Permutations | Practice | GeeksforGeeks
Given a string S. The task is to find all permutations (need not be different) of a given string.
Example 1:
Input:
S = AAA
Output: AAA AAA AAA AAA AAA AAAExplanation: There are total 6 permutations, as given in the output.
Example 2:
Input:
S = ABS
Example 1:
Input:
S = AAA
Output: AAA AAA AAA AAA AAA AAAExplanation: There are total 6 permutations, as given in the output.
Example 2:
Input:
S = ABS
๐3
Problem Of The Day
"Solve the Sudoku"
Given an incomplete Sudoku configuration in terms of a 9 x 9 2-D square matrix (grid[][]), the task is to find a solved Sudoku. For simplicity, you may assume that there will be only one unique solution.
A sudoku solution must satisfy all of the following rules:
Each of the digits 1-9 must occur exactly once in each row.
Each of the digits 1-9 must occur exactly once in each column.
Each of the digits 1-9 must occur exactly once in each of the 9 3x3 sub-boxes of the grid.
Zeros in the grid indicates blanks, which are to be filled with some number between 1-9. You can not replace the element in the cell which is not blank.
Sample Sudoku for you to get the logic for its solution:
Example 1:
Input:
grid[][] =
[[3 0 6 5 0 8 4 0 0],
[5 2 0 0 0 0 0 0 0],
[0 8 7 0 0 0 0 3 1 ],
[0 0 3 0 1 0 0 8 0],
[9 0 0 8 6 3 0 0 5],
[0 5 0 0 9 0 6 0 0],
[1 3 0 0 0 0 2 5 0],
[0 0 0 0 0 0 0 7 4],
[0 0 5 2 0 6 3 0 0]]
Output:
True
3 1 6 5 7 8 4 9 2
5 2 9 1 3 4 7 6 8
4 8 7 6 2 9 5 3 1
2 6 3 4 1 5 9 8 7
9 7 4 8 6 3 1 2 5
8 5 1 7 9 2 6 4 3
1 3 8 9 4 7 2 5 6
6 9 2 3 5 1 8 7 4
7 4 5 2 8 6 3 1 9
Explanation:
There exists a valid Sudoku for the input grid, which is shown in output.
Example 2:
Input:
grid[][] =
[[3 6 6 5 0 8 4 0 0],
[5 2 0 0 0 0 0 0 0],
[0 8 7 0 0 0 0 3 1 ],
[0 0 3 0 1 0 0 8 0],
[9 0 0 8 6 3 0 0 5],
[0 5 0 0 9 0 6 0 0],
[1 3 0 0 0 0 2 5 0],
[0 0 0 0 0 0 0 7 4],
[0 0 5 2 0 6 3 0 0]]
Output:
False
Explanation:
There does not exists a valid Sudoku for the input grid, since there are two 6s in the first row. Which cannot replaced.
Your Task:
You need to complete the two functions:
SolveSudoku(): Takes a grid as its argument and returns true if a solution is possible and false if it is not.
printGrid(): Takes a grid as its argument and prints the 81 numbers of the solved Sudoku in a single line with space separation.
NOTE: Do not give a new line character after printing the grid. It has already been taken care of in the Driver Code.
Expected Time Complexity: O(9N*N).
Expected Auxiliary Space: O(N*N).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/solve-the-sudoku-1587115621/1
"Solve the Sudoku"
Given an incomplete Sudoku configuration in terms of a 9 x 9 2-D square matrix (grid[][]), the task is to find a solved Sudoku. For simplicity, you may assume that there will be only one unique solution.
A sudoku solution must satisfy all of the following rules:
Each of the digits 1-9 must occur exactly once in each row.
Each of the digits 1-9 must occur exactly once in each column.
Each of the digits 1-9 must occur exactly once in each of the 9 3x3 sub-boxes of the grid.
Zeros in the grid indicates blanks, which are to be filled with some number between 1-9. You can not replace the element in the cell which is not blank.
Sample Sudoku for you to get the logic for its solution:
Example 1:
Input:
grid[][] =
[[3 0 6 5 0 8 4 0 0],
[5 2 0 0 0 0 0 0 0],
[0 8 7 0 0 0 0 3 1 ],
[0 0 3 0 1 0 0 8 0],
[9 0 0 8 6 3 0 0 5],
[0 5 0 0 9 0 6 0 0],
[1 3 0 0 0 0 2 5 0],
[0 0 0 0 0 0 0 7 4],
[0 0 5 2 0 6 3 0 0]]
Output:
True
3 1 6 5 7 8 4 9 2
5 2 9 1 3 4 7 6 8
4 8 7 6 2 9 5 3 1
2 6 3 4 1 5 9 8 7
9 7 4 8 6 3 1 2 5
8 5 1 7 9 2 6 4 3
1 3 8 9 4 7 2 5 6
6 9 2 3 5 1 8 7 4
7 4 5 2 8 6 3 1 9
Explanation:
There exists a valid Sudoku for the input grid, which is shown in output.
Example 2:
Input:
grid[][] =
[[3 6 6 5 0 8 4 0 0],
[5 2 0 0 0 0 0 0 0],
[0 8 7 0 0 0 0 3 1 ],
[0 0 3 0 1 0 0 8 0],
[9 0 0 8 6 3 0 0 5],
[0 5 0 0 9 0 6 0 0],
[1 3 0 0 0 0 2 5 0],
[0 0 0 0 0 0 0 7 4],
[0 0 5 2 0 6 3 0 0]]
Output:
False
Explanation:
There does not exists a valid Sudoku for the input grid, since there are two 6s in the first row. Which cannot replaced.
Your Task:
You need to complete the two functions:
SolveSudoku(): Takes a grid as its argument and returns true if a solution is possible and false if it is not.
printGrid(): Takes a grid as its argument and prints the 81 numbers of the solved Sudoku in a single line with space separation.
NOTE: Do not give a new line character after printing the grid. It has already been taken care of in the Driver Code.
Expected Time Complexity: O(9N*N).
Expected Auxiliary Space: O(N*N).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/solve-the-sudoku-1587115621/1
practice.geeksforgeeks.org
Solve the Sudoku | Practice | GeeksforGeeks
Given an incomplete Sudoku configuration in terms of a 9 x 9 2-D square matrix (grid[][]), the task is to find a solved Sudoku. For simplicity, you may assume that there will be only one unique solution.
A sudoku solution must satisfy
A sudoku solution must satisfy