Must Do DSA Topics Day 100
Projects
Make Notepad using Tkinter : Letβs see how to create a simple notepad in Python using Tkinter. This notepad GUI will consist of various menu like file and edit, using which all functionalities like saving the file, opening a file, editing, cut and paste can be done.
Learn more : http://bit.ly/3XTwHkC
Color game using Tkinter in Python : TKinter is widely used for developing GUI applications. Along with applications, we can also use Tkinter GUI to develop games. Letβs try to make a game using Tkinter.
Learn more : http://bit.ly/3kWXrlC
Python | Message Encode-Decode using Tkinter : Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is most commonly used method.
Learn more : http://bit.ly/3DPeNaL
Get access to all the projects : https://www.geeksforgeeks.org/computer-science-projects/?ref=sh
Projects
Make Notepad using Tkinter : Letβs see how to create a simple notepad in Python using Tkinter. This notepad GUI will consist of various menu like file and edit, using which all functionalities like saving the file, opening a file, editing, cut and paste can be done.
Learn more : http://bit.ly/3XTwHkC
Color game using Tkinter in Python : TKinter is widely used for developing GUI applications. Along with applications, we can also use Tkinter GUI to develop games. Letβs try to make a game using Tkinter.
Learn more : http://bit.ly/3kWXrlC
Python | Message Encode-Decode using Tkinter : Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is most commonly used method.
Learn more : http://bit.ly/3DPeNaL
Get access to all the projects : https://www.geeksforgeeks.org/computer-science-projects/?ref=sh
π¨Job Alert π¨
NCode Technologies is hiring for WordPress Developer in 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/NCode-Wordpress
NCode Technologies is hiring for WordPress Developer in 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/NCode-Wordpress
Problem Of The Day
"Distinct Coloring"
Solve the problem to win points
There is a row of N houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color. Find the minimum cost to paint all houses.
The cost of painting each house in red, blue or green colour is given in the array r[], g[] and b[] respectively.
Example 1:
Input:
N = 3
r[] = {1, 1, 1}
g[] = {2, 2, 2}
b[] = {3, 3, 3}
Output: 4
Explanation: We can color the houses
in RGR manner to incur minimum cost.
We could have obtained a cost of 3 if
we coloured all houses red, but we
cannot color adjacent houses with
the same color.
Example 2:
Input:
N = 3
r[] = {2, 1, 3}
g[] = {3, 2, 1}
b[] = {1, 3, 2}
Output: 3
Explanation: We can color the houses
in BRG manner to incur minimum cost.
Your Task:
You don't need to read input or print anything. Your task is to complete the function distinctColoring() which takes the size N and the color arrays r[], g[], b[] as input parameters and returns the minimum cost of coloring such that the color of no two houses is same.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/844b4fdcd988ac5461324d62d43f7892749a113c/1
Powered by hirist.com
"Distinct Coloring"
Solve the problem to win points
There is a row of N houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color. Find the minimum cost to paint all houses.
The cost of painting each house in red, blue or green colour is given in the array r[], g[] and b[] respectively.
Example 1:
Input:
N = 3
r[] = {1, 1, 1}
g[] = {2, 2, 2}
b[] = {3, 3, 3}
Output: 4
Explanation: We can color the houses
in RGR manner to incur minimum cost.
We could have obtained a cost of 3 if
we coloured all houses red, but we
cannot color adjacent houses with
the same color.
Example 2:
Input:
N = 3
r[] = {2, 1, 3}
g[] = {3, 2, 1}
b[] = {1, 3, 2}
Output: 3
Explanation: We can color the houses
in BRG manner to incur minimum cost.
Your Task:
You don't need to read input or print anything. Your task is to complete the function distinctColoring() which takes the size N and the color arrays r[], g[], b[] as input parameters and returns the minimum cost of coloring such that the color of no two houses is same.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/844b4fdcd988ac5461324d62d43f7892749a113c/1
Powered by hirist.com
practice.geeksforgeeks.org
Distinct Coloring | Practice | GeeksforGeeks
There is a row of N houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the
π9β€1
Problem Of The Day
"Largest Sum Cycle"
Solve the problem to win points
Given a maze with N cells. Each cell may have multiple entry points but not more than one exit(i.e entry/exit points are unidirectional doors like valves).
You are given an array Edge[] of N integers, where Edge[i] contains the cell number that can be reached from of cell i in one step. Edge[i] is -1 if the ith cell doesn't have an exit.
The task is to find the largest sum of a cycle in the maze(Sum of a cycle is the sum of the cell indexes of all cells present in that cycle).
Note:The cells are named with an integer value from 0 to N-1. If there is no cycle in the graph then return -1.
Example 1:
Input:
N = 4
Edge[] = {1, 2, 0, -1}
Output: 3
Explanation:
There is only one cycle in the graph.
(i.e 0->1->2->0)
Sum of the cell index in that cycle
= 0 + 1 + 2 = 3.
Example 2:
Input:
N = 4
Edge[] = {2, 0, -1, 2}
Output: -1
Explanation:
1 -> 0 -> 2 <- 3
There is no cycle in the graph.
Your task:
You dont need to read input or print anything. Your task is to complete the function largestSumCycle() which takes the integer N denoting the number of cells and the array Edge[] as input parameters and returns the sum of the largest sum cycle in the maze.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/51afa710a708c0681748445b509696dd588d5c40/1
Powered by hirist.com
"Largest Sum Cycle"
Solve the problem to win points
Given a maze with N cells. Each cell may have multiple entry points but not more than one exit(i.e entry/exit points are unidirectional doors like valves).
You are given an array Edge[] of N integers, where Edge[i] contains the cell number that can be reached from of cell i in one step. Edge[i] is -1 if the ith cell doesn't have an exit.
The task is to find the largest sum of a cycle in the maze(Sum of a cycle is the sum of the cell indexes of all cells present in that cycle).
Note:The cells are named with an integer value from 0 to N-1. If there is no cycle in the graph then return -1.
Example 1:
Input:
N = 4
Edge[] = {1, 2, 0, -1}
Output: 3
Explanation:
There is only one cycle in the graph.
(i.e 0->1->2->0)
Sum of the cell index in that cycle
= 0 + 1 + 2 = 3.
Example 2:
Input:
N = 4
Edge[] = {2, 0, -1, 2}
Output: -1
Explanation:
1 -> 0 -> 2 <- 3
There is no cycle in the graph.
Your task:
You dont need to read input or print anything. Your task is to complete the function largestSumCycle() which takes the integer N denoting the number of cells and the array Edge[] as input parameters and returns the sum of the largest sum cycle in the maze.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/51afa710a708c0681748445b509696dd588d5c40/1
Powered by hirist.com
practice.geeksforgeeks.org
Largest Sum Cycle | Practice | GeeksforGeeks
Given a maze with N cells. Each cell may have multiple entry points but not more than one exit(i.e entry/exit points are unidirectional doors like valves).
You are given an array Edge[] of N integers, where Edge[i]
You are given an array Edge[] of N integers, where Edge[i]
animation.gif
11.7 MB
Must Learn!π‘
ChatGPT by OpenAI has created a buzz around. With its launch, it gained over 1+ million users in just 5 days.
While some people are impressed by its functioning, others are confused and curious to know about it.
However, there's a lot to know about this new sensation. This article explains the ChatCPT's functioning, reliability, and usage in detail. Give it a read.
https://www.geeksforgeeks.org/how-to-build-a-chatgpt-like-image-generator-application-in-android/
ChatGPT by OpenAI has created a buzz around. With its launch, it gained over 1+ million users in just 5 days.
While some people are impressed by its functioning, others are confused and curious to know about it.
However, there's a lot to know about this new sensation. This article explains the ChatCPT's functioning, reliability, and usage in detail. Give it a read.
https://www.geeksforgeeks.org/how-to-build-a-chatgpt-like-image-generator-application-in-android/
π5
Problem Of The Day
"Coordinates of the last cell in a Matrix on which performing given operations exits from the Matrix"
Solve the problem to win points
Given a binary matrix of dimensions N * M. One can perform the given operation into the matrix.
If the value of matrix[i][j] is 0, then traverse in the same direction and check the next value.
If the value of matrix[i][j] is 1, then update matrix[i][j] to 0 and change the current direction from up, right, down, or left to the directions right, down, left, and up respectively.
Initially you start from cell(0, 0), moving in right direction.
The task is to find the indices of the matrix which leads to outside the matrix from the traversal of the given matrix from the cell (0, 0) by performing the operations.
Example 1:
Input:
matrix[][] = {{0,1},
{1,0}}
Output: (1,1)
Explanation:
Example 2:
Input:
matrix[][] = {{0, 1, 1, 1, 0},
{1, 0, 1, 0, 1},
{1, 1, 1, 0, 0}}
Output: (2,0)
Explanation: We will leave the grid after visiting the index (2,0).
Your Task:
You don't need to read input or print anything. Complete the function endPoints() that take the matrix as input parameter and output the last cell before the pointer gets outside of the matrix.
Expected Time Complexity: O(N)
Expected Space Complexity: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/2e068e2342b9c9f40cfda1ed8e8119542d748fd8/1
Powered by hirist.com
"Coordinates of the last cell in a Matrix on which performing given operations exits from the Matrix"
Solve the problem to win points
Given a binary matrix of dimensions N * M. One can perform the given operation into the matrix.
If the value of matrix[i][j] is 0, then traverse in the same direction and check the next value.
If the value of matrix[i][j] is 1, then update matrix[i][j] to 0 and change the current direction from up, right, down, or left to the directions right, down, left, and up respectively.
Initially you start from cell(0, 0), moving in right direction.
The task is to find the indices of the matrix which leads to outside the matrix from the traversal of the given matrix from the cell (0, 0) by performing the operations.
Example 1:
Input:
matrix[][] = {{0,1},
{1,0}}
Output: (1,1)
Explanation:
Example 2:
Input:
matrix[][] = {{0, 1, 1, 1, 0},
{1, 0, 1, 0, 1},
{1, 1, 1, 0, 0}}
Output: (2,0)
Explanation: We will leave the grid after visiting the index (2,0).
Your Task:
You don't need to read input or print anything. Complete the function endPoints() that take the matrix as input parameter and output the last cell before the pointer gets outside of the matrix.
Expected Time Complexity: O(N)
Expected Space Complexity: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/2e068e2342b9c9f40cfda1ed8e8119542d748fd8/1
Powered by hirist.com
practice.geeksforgeeks.org
Coordinates of the last cell in a Matrix on which performing given operations exits from the Matrix | Practice | GeeksforGeeks
Given a binary matrix of dimensions N * M. One can perform the given operation into the matrix.
If the value of matrix[i][j] is 0, then traverse in the same direction and check the next value.
If the value of&nbs
If the value of matrix[i][j] is 0, then traverse in the same direction and check the next value.
If the value of&nbs
π1
This media is not supported in your browser
VIEW IN TELEGRAM
Must Learn!π‘
While it must be an immense pleasure for you to fulfill your dream of becoming a developer, it is surely confusing to choose between FrontEnd or BackEnd.
So, which one should you choose?
This article will help you in making the best decision with a detailed description of both options. Give it a read.
Link- https://www.geeksforgeeks.org/frontend-vs-backend-which-one-should-i-choose/
While it must be an immense pleasure for you to fulfill your dream of becoming a developer, it is surely confusing to choose between FrontEnd or BackEnd.
So, which one should you choose?
This article will help you in making the best decision with a detailed description of both options. Give it a read.
Link- https://www.geeksforgeeks.org/frontend-vs-backend-which-one-should-i-choose/
π2
Problem Of The Day
"Max Sum without Adjacents"
Solve the problem to win points
Given an array Arr of size N containing positive integers. Find the maximum sum of a subsequence such that no two numbers in the sequence should be adjacent in the array.
Example 1:
Input:
N = 6
Arr[] = {5, 5, 10, 100, 10, 5}
Output: 110
Explanation: If you take indices 0, 3
and 5, then Arr[0]+Arr[3]+Arr[5] =
5+100+5 = 110.
Example 2:
Input:
N = 4
Arr[] = {3, 2, 7, 10}
Output: 13
Explanation: 3 and 10 forms a non
continuous subsequence with maximum
sum.
Your Task:
You don't need to read input or print anything. Your task is to complete the function findMaxSum() which takes the array of integers arr and n as parameters and returns an integer denoting the answer. It is guaranteed that your answer will always fit in the 32-bit integer.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/7a33c749a79327b2889d420dd80342fff33aac6d/1
Powered by hirist.com
"Max Sum without Adjacents"
Solve the problem to win points
Given an array Arr of size N containing positive integers. Find the maximum sum of a subsequence such that no two numbers in the sequence should be adjacent in the array.
Example 1:
Input:
N = 6
Arr[] = {5, 5, 10, 100, 10, 5}
Output: 110
Explanation: If you take indices 0, 3
and 5, then Arr[0]+Arr[3]+Arr[5] =
5+100+5 = 110.
Example 2:
Input:
N = 4
Arr[] = {3, 2, 7, 10}
Output: 13
Explanation: 3 and 10 forms a non
continuous subsequence with maximum
sum.
Your Task:
You don't need to read input or print anything. Your task is to complete the function findMaxSum() which takes the array of integers arr and n as parameters and returns an integer denoting the answer. It is guaranteed that your answer will always fit in the 32-bit integer.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/7a33c749a79327b2889d420dd80342fff33aac6d/1
Powered by hirist.com
practice.geeksforgeeks.org
Max Sum without Adjacents | Practice | GeeksforGeeks
Given an array Arr of size N containing positive integers. Find the maximum sum of a subsequence such that no two numbers in the sequence should be adjacent in the array.
Example 1:
Input:
N = 6
Arr[] = {5, 5, 10, 100, 10, 5
Example 1:
Input:
N = 6
Arr[] = {5, 5, 10, 100, 10, 5
π2
This media is not supported in your browser
VIEW IN TELEGRAM
Must Learn! π‘
Among the most issues that we face include 'Time Management', which is a life skill. It is an art to master in this field.
So, why do most of us fail to manage our time?
It's because we lack the right tactics and ways to manage our time. This article discusses the best 5 ways to improve your time management skills.
Give it a read- https://www.geeksforgeeks.org/ways-to-improve-time-management-skills/
Among the most issues that we face include 'Time Management', which is a life skill. It is an art to master in this field.
So, why do most of us fail to manage our time?
It's because we lack the right tactics and ways to manage our time. This article discusses the best 5 ways to improve your time management skills.
Give it a read- https://www.geeksforgeeks.org/ways-to-improve-time-management-skills/
Problem Of The Day
"Intersection Point in Y Shaped Linked Lists"
Solve the problem to win points
Given two singly linked lists of size N and M, write a program to get the point where two linked lists intersect each other.
Example 1:
Input:
LinkList1 = 3->6->9->common
LinkList2 = 10->common
common = 15->30->NULL
Output: 15
Explanation:
Y ShapedLinked List
Example 2:
Input:
Linked List 1 = 4->1->common
Linked List 2 = 5->6->1->common
common = 8->4->5->NULL
Output: 8
Explanation:
4 5
| |
1 6
\ /
8 ----- 1
|
4
|
5
|
NULL
Your Task:
You don't need to read input or print anything. The task is to complete the function intersetPoint() which takes the pointer to the head of linklist1(head1) and linklist2(head2) as input parameters and returns data value of a node where two linked lists intersect. If linked list do not merge at any point, then it should return -1.
Challenge : Try to solve the problem without using any extra space.
Expected Time Complexity: O(N+M)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/eae1fbd0ac8f213a833d231e26ba4d829e79dd9c/1
Powered by hirist.com
"Intersection Point in Y Shaped Linked Lists"
Solve the problem to win points
Given two singly linked lists of size N and M, write a program to get the point where two linked lists intersect each other.
Example 1:
Input:
LinkList1 = 3->6->9->common
LinkList2 = 10->common
common = 15->30->NULL
Output: 15
Explanation:
Y ShapedLinked List
Example 2:
Input:
Linked List 1 = 4->1->common
Linked List 2 = 5->6->1->common
common = 8->4->5->NULL
Output: 8
Explanation:
4 5
| |
1 6
\ /
8 ----- 1
|
4
|
5
|
NULL
Your Task:
You don't need to read input or print anything. The task is to complete the function intersetPoint() which takes the pointer to the head of linklist1(head1) and linklist2(head2) as input parameters and returns data value of a node where two linked lists intersect. If linked list do not merge at any point, then it should return -1.
Challenge : Try to solve the problem without using any extra space.
Expected Time Complexity: O(N+M)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/eae1fbd0ac8f213a833d231e26ba4d829e79dd9c/1
Powered by hirist.com
practice.geeksforgeeks.org
Intersection Point in Y Shaped Linked Lists | Practice | GeeksforGeeks
Given two singly linked lists of size N and M, write a program to get the point where two linked lists intersect each other.
Example 1:
Input:
LinkList1 = 3->6->9->common
LinkList2 = 10->common
common = 15->30->
Example 1:
Input:
LinkList1 = 3->6->9->common
LinkList2 = 10->common
common = 15->30->
π1
Must Learn!π‘
When it comes to programming languages, we have so many options yet we stuck at some point due to confusion.
So, what programming languages are must-haves in 2023?
We have the answer. This article explains and elaborates on the top 10 programming languages that you must learn in 2023.
Give it a read- https://www.geeksforgeeks.org/top-10-programming-languages-to-learn/
When it comes to programming languages, we have so many options yet we stuck at some point due to confusion.
So, what programming languages are must-haves in 2023?
We have the answer. This article explains and elaborates on the top 10 programming languages that you must learn in 2023.
Give it a read- https://www.geeksforgeeks.org/top-10-programming-languages-to-learn/
π4
Problem Of The Day
"BST Downward Traversal"
Solve the problem to win points
Given a Binary Search Tree and a target value. You have to find the node whose data is equal to target and return the sum of all descendant node's data which are vertically below the target node. Initially you are at the root node.
Note: If target node is not present in bst then return -1.
Example 1:
Input:
Target = 35
Output: 32
Explanation: Vertically below 35 is 32.
Example 2:
Input:
Target = 25
Output: 52
Explanation: Vertically below 25 is 22, 30 and their sum is 52.
Your Task:
You don't need to read input or print anything. Your task is to complete the function verticallyDownBST() which takes BST(you are given root node of bst ) and target as input, and return an interger value as the sum of vertically down nodes from target. If target is not present in bst then return -1.
Expected Time Complexity: O( n ), n is number of nodes.
Expected Auxiliary Space: O(Height of the tree).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/c85e3a573a7de6dfd18398def16d05387852b319/1
Powered by hirist.com
"BST Downward Traversal"
Solve the problem to win points
Given a Binary Search Tree and a target value. You have to find the node whose data is equal to target and return the sum of all descendant node's data which are vertically below the target node. Initially you are at the root node.
Note: If target node is not present in bst then return -1.
Example 1:
Input:
Target = 35
Output: 32
Explanation: Vertically below 35 is 32.
Example 2:
Input:
Target = 25
Output: 52
Explanation: Vertically below 25 is 22, 30 and their sum is 52.
Your Task:
You don't need to read input or print anything. Your task is to complete the function verticallyDownBST() which takes BST(you are given root node of bst ) and target as input, and return an interger value as the sum of vertically down nodes from target. If target is not present in bst then return -1.
Expected Time Complexity: O( n ), n is number of nodes.
Expected Auxiliary Space: O(Height of the tree).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/c85e3a573a7de6dfd18398def16d05387852b319/1
Powered by hirist.com
practice.geeksforgeeks.org
BST Downward Traversal | Practice | GeeksforGeeks
Given a Binary Search Tree and a target value. You have to find the node whose data is equal to target and return the sum of all descendant node's data which are vertically below the target node. Initially you are at the root node.
Note: If targ
Note: If targ
π1
Must Learn!π‘
You maybe unaware of the fact that nobody can analyse your strengths and weaknesses better than you. However, most of us have no idea how to do that.
So, what is the best technique to do so? SWOT Analysis.
A SWOT Analysis assesses your Strengths, Weaknesses, Opportunities, and Threats, giving you clarity for your future decisions.
This article will help you learn to go through all the steps of SWOT Analysis.
Give it a read: https://www.geeksforgeeks.org/personal-swot-analysis-with-examples/?utm_source=geeksforgeeks&utm_medium=newui_home&utm_campaign=articles
You maybe unaware of the fact that nobody can analyse your strengths and weaknesses better than you. However, most of us have no idea how to do that.
So, what is the best technique to do so? SWOT Analysis.
A SWOT Analysis assesses your Strengths, Weaknesses, Opportunities, and Threats, giving you clarity for your future decisions.
This article will help you learn to go through all the steps of SWOT Analysis.
Give it a read: https://www.geeksforgeeks.org/personal-swot-analysis-with-examples/?utm_source=geeksforgeeks&utm_medium=newui_home&utm_campaign=articles
π3
π¨ Job Alert π¨
Zibtek is hiring for iOS Developer in Bangalore (Kasturinagar).
Experience - 2+ Years
Apply by - Feb 28, 2023
Apply via the following link and share the opportunity with your friends - https://practice.geeksforgeeks.org/jobs/Zibtek-iOS
Zibtek is hiring for iOS Developer in Bangalore (Kasturinagar).
Experience - 2+ Years
Apply by - Feb 28, 2023
Apply via the following link and share the opportunity with your friends - https://practice.geeksforgeeks.org/jobs/Zibtek-iOS
π3
Problem Of The Day
"Length of the longest subarray with positive product"
Solve the problem to win points
Given an array arr[] consisting of n integers, find the length of the longest subarray with positive (non zero) product.
Example 1:
Input:
arr[] ={0, 1, -2, -3, -4}
Output:
3
Explanation:
The longest subarray with positive product is:
{1, -2, -3}.Therefore, the required length is 3.
Example 2:
Input:
arr[]={-1, -2, 0, 1, 2}
Output:
2
Explanation:
The longest subarray with positive products
are: {-1, -2}, {1, 2}. Therefore, the required
length is 2.
Your Task: This is a function problem. You don't need to take any input, as it is already accomplished by the driver code. You just need to complete the function maxLength() that takes array arr[], and an integer n as parameters and return the length of the longest subarray where the product of all of its element is positive.
Expected Time Complexity: O(n).
Expected Auxiliary Space: O(1).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/4dfa8ba14d4c94f4d7637b6b5246782412f3aeb8/1
Powered by hirist.com
"Length of the longest subarray with positive product"
Solve the problem to win points
Given an array arr[] consisting of n integers, find the length of the longest subarray with positive (non zero) product.
Example 1:
Input:
arr[] ={0, 1, -2, -3, -4}
Output:
3
Explanation:
The longest subarray with positive product is:
{1, -2, -3}.Therefore, the required length is 3.
Example 2:
Input:
arr[]={-1, -2, 0, 1, 2}
Output:
2
Explanation:
The longest subarray with positive products
are: {-1, -2}, {1, 2}. Therefore, the required
length is 2.
Your Task: This is a function problem. You don't need to take any input, as it is already accomplished by the driver code. You just need to complete the function maxLength() that takes array arr[], and an integer n as parameters and return the length of the longest subarray where the product of all of its element is positive.
Expected Time Complexity: O(n).
Expected Auxiliary Space: O(1).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/4dfa8ba14d4c94f4d7637b6b5246782412f3aeb8/1
Powered by hirist.com
practice.geeksforgeeks.org
Length of the longest subarray with positive product | Practice | GeeksforGeeks
Given an array arr[] consisting of n integers, find the length of the longest subarray with positive (non zero) product.
Example 1:
Input:
arr[] ={0, 1, -2, -3, -4}
Output:
3
Explanation:
The lon
Example 1:
Input:
arr[] ={0, 1, -2, -3, -4}
Output:
3
Explanation:
The lon
π2β€1
This media is not supported in your browser
VIEW IN TELEGRAM
Must Learn!π‘
ChatGPT by OpenAI has created a buzz around. With its launch, it gained over 1+ million users in just 5 days.
While some people are impressed by its functioning, others are confused and curious to know about the technology used in making chatbot like tool.
Do you also want to make something like this? This will help you in doing so. Give it a read and learn how to build a ChatGPT-like image generator application in android.
Link - https://www.geeksforgeeks.org/how-to-build-a-chatgpt-like-image-generator-application-in-android/?utm_source=geeksforgeeks&utm_medium=newui_home&utm_campaign=articles
ChatGPT by OpenAI has created a buzz around. With its launch, it gained over 1+ million users in just 5 days.
While some people are impressed by its functioning, others are confused and curious to know about the technology used in making chatbot like tool.
Do you also want to make something like this? This will help you in doing so. Give it a read and learn how to build a ChatGPT-like image generator application in android.
Link - https://www.geeksforgeeks.org/how-to-build-a-chatgpt-like-image-generator-application-in-android/?utm_source=geeksforgeeks&utm_medium=newui_home&utm_campaign=articles
Problem Of The Day
"Count number of free cell"
Solve the problem to win points
Given a Matrix size N*N and an integer K. Initially, the matrix contains only 0. You are given K tasks and for each task, you are given two coordinates (r,c) [1 based index]. Where coordinates (r,c) denotes rth row and cth column of the given matrix.
You have to perform each task sequentially in the given order. For each task, You have to put 1 in all rth row cells and all cth columns cells.
After each task, You have to calculate the number of 0 present in the matrix and return it.
Example 1:
Input:
n = 3, k= 3
2 2
2 3
3 2
Output: 4 2 1
Explanation:
After 1st Operation, all the 2nd row
and all the 2nd column will be filled by
1. So remaning cell with value 0 will be 4
After 2nd Operation, all the 2nd row and all
the 3rd column will be filled by 1. So
remaning cell with value 0 will be 2.
After 3rd Operation cells having value 0 will
be 1.
Example 2:
Input:
n = 2, k = 2
1 2
1 1
Output: 1 0
Your Task:
The task is to complete the function countZero(), which takes parameter n, size of
the matrix, k no of operation and array arr[][], which denotes the position of the cells.
You have to return an array that contains all the results.
Expected Time Complexity: O( k ).
Expected Auxiliary Space: O( n+n+k ).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/90a81c305b1fe939b9230a67824749ceaa493eab/1
Powered by hirist.com
"Count number of free cell"
Solve the problem to win points
Given a Matrix size N*N and an integer K. Initially, the matrix contains only 0. You are given K tasks and for each task, you are given two coordinates (r,c) [1 based index]. Where coordinates (r,c) denotes rth row and cth column of the given matrix.
You have to perform each task sequentially in the given order. For each task, You have to put 1 in all rth row cells and all cth columns cells.
After each task, You have to calculate the number of 0 present in the matrix and return it.
Example 1:
Input:
n = 3, k= 3
2 2
2 3
3 2
Output: 4 2 1
Explanation:
After 1st Operation, all the 2nd row
and all the 2nd column will be filled by
1. So remaning cell with value 0 will be 4
After 2nd Operation, all the 2nd row and all
the 3rd column will be filled by 1. So
remaning cell with value 0 will be 2.
After 3rd Operation cells having value 0 will
be 1.
Example 2:
Input:
n = 2, k = 2
1 2
1 1
Output: 1 0
Your Task:
The task is to complete the function countZero(), which takes parameter n, size of
the matrix, k no of operation and array arr[][], which denotes the position of the cells.
You have to return an array that contains all the results.
Expected Time Complexity: O( k ).
Expected Auxiliary Space: O( n+n+k ).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/90a81c305b1fe939b9230a67824749ceaa493eab/1
Powered by hirist.com
practice.geeksforgeeks.org
Count number of free cell | Practice | GeeksforGeeks
Given a Matrix size N*N and an integer K. Initially, the matrix contains only 0. You are given K tasks and for each task, you are given two coordinates (r,c) [1 based index]. Where coordinates (r,c) denotes rth row and cth column of the giv
π2β€1
Must Learn!π‘
Blockchain is talk of the town, since it has entered not just tech space, but finance, supply chain, healthcare, etc.
So, what is a blockchain? How is it helping different sectors?
It is a distributed digital ledger that records transactions across a network of computers.
This article talks about blockchain technology's revolution in different industries. Give it a read - https://www.geeksforgeeks.org/how-blockchain-technology-is-revolutionizing-industries/?utm_source=geeksforgeeks&utm_medium=newui_home&utm_campaign=articles
Blockchain is talk of the town, since it has entered not just tech space, but finance, supply chain, healthcare, etc.
So, what is a blockchain? How is it helping different sectors?
It is a distributed digital ledger that records transactions across a network of computers.
This article talks about blockchain technology's revolution in different industries. Give it a read - https://www.geeksforgeeks.org/how-blockchain-technology-is-revolutionizing-industries/?utm_source=geeksforgeeks&utm_medium=newui_home&utm_campaign=articles
π¨Job Alertπ¨
Pensieve is hiring for Frontend Developer.
Location - Remote (India)
Experience - 1-8 Years
Apply by - Feb 28, 2023
Apply via the following link and share the opportunity with your friends - https://practice.geeksforgeeks.org/jobs/Pensieveid_Frontendev
Visit our jobs portal 'Get Hired With GeeksforGeeks' for more such job opportunities - https://practice.geeksforgeeks.org/jobs
Pensieve is hiring for Frontend Developer.
Location - Remote (India)
Experience - 1-8 Years
Apply by - Feb 28, 2023
Apply via the following link and share the opportunity with your friends - https://practice.geeksforgeeks.org/jobs/Pensieveid_Frontendev
Visit our jobs portal 'Get Hired With GeeksforGeeks' for more such job opportunities - https://practice.geeksforgeeks.org/jobs
Problem Of The Day
"Maximum Bipartite Matching"
Solve the problem to win points
There are M job applicants and N jobs. Each applicant has a subset of jobs that he/she is interested in. Each job opening can only accept one applicant and a job applicant can be appointed for only one job. Given a matrix G with M rows and N columns where G(i,j) denotes ith applicant is interested in the jth job. Find the maximum number of applicants who can get the job.
Example 1:
Input:
M = 3, N = 5
G = {{1,1,0,1,1},{0,1,0,0,1},
{1,1,0,1,1}}
Output: 3
Explanation: There is one of the possible
assignment-
First applicant gets the 1st job.
Second applicant gets the 2nd job.
Third applicant gets the 4th job.
Example 2:
Input:
M = 6, N = 2
G = {{1,1},{0,1},{0,1},{0,1},
{0,1},{1,0}}
Output: 2
Explanation: There is one of the possible
assignment-
First applicant gets the 1st job.
Second applicant gets the 2nd job.
Your Task:
You don't need to read to print anything. Your task is to complete the function maximumMatch() which takes matrix G as input parameter and returns the maximum number of applicants who can get the job.
Expected Time Complexity: O(N3).
Expected Auxiliary Space: O(N).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/9a88fe7ada1c49c2b3da7a67b43875e4a76aface/1
Powered by hirist.com
"Maximum Bipartite Matching"
Solve the problem to win points
There are M job applicants and N jobs. Each applicant has a subset of jobs that he/she is interested in. Each job opening can only accept one applicant and a job applicant can be appointed for only one job. Given a matrix G with M rows and N columns where G(i,j) denotes ith applicant is interested in the jth job. Find the maximum number of applicants who can get the job.
Example 1:
Input:
M = 3, N = 5
G = {{1,1,0,1,1},{0,1,0,0,1},
{1,1,0,1,1}}
Output: 3
Explanation: There is one of the possible
assignment-
First applicant gets the 1st job.
Second applicant gets the 2nd job.
Third applicant gets the 4th job.
Example 2:
Input:
M = 6, N = 2
G = {{1,1},{0,1},{0,1},{0,1},
{0,1},{1,0}}
Output: 2
Explanation: There is one of the possible
assignment-
First applicant gets the 1st job.
Second applicant gets the 2nd job.
Your Task:
You don't need to read to print anything. Your task is to complete the function maximumMatch() which takes matrix G as input parameter and returns the maximum number of applicants who can get the job.
Expected Time Complexity: O(N3).
Expected Auxiliary Space: O(N).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/9a88fe7ada1c49c2b3da7a67b43875e4a76aface/1
Powered by hirist.com
practice.geeksforgeeks.org
Maximum Bipartite Matching | Practice | GeeksforGeeks
There are M job applicants and N jobs. Each applicant has a subset of jobs that he/she is interested in. Each job opening can only accept one applicant and a job applicant can be appointed for only one job. Given a matrix G with M rows and
π1