We are now on threads tooo!
.
.
20K have already joined, come and join the fun: https://www.threads.net/@geeks_for_geeks
.
.
20K have already joined, come and join the fun: https://www.threads.net/@geeks_for_geeks
β€1
Problem Of The Day
"Find triplets with zero sum"
Given an array arr[] of n integers. Check whether it contains a triplet that sums up to zero.
Note: Return 1, if there is at least one triplet following the condition else return 0.
Example 1:
Input: n = 5, arr[] = {0, -1, 2, -3, 1}
Output: 1
Explanation: 0, -1 and 1 forms a triplet
with sum equal to 0.
Example 2:
Input: n = 3, arr[] = {1, 2, 3}
Output: 0
Explanation: No triplet with zero sum exists.
Your Task:
You don't need to read input or print anything. Your task is to complete the boolean function findTriplets() which takes the array arr[] and the size of the array (n) as inputs and print 1 if the function returns true else print 0 if the function returns false.
Expected Time Complexity: O(n2)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/find-triplets-with-zero-sum/1
"Find triplets with zero sum"
Given an array arr[] of n integers. Check whether it contains a triplet that sums up to zero.
Note: Return 1, if there is at least one triplet following the condition else return 0.
Example 1:
Input: n = 5, arr[] = {0, -1, 2, -3, 1}
Output: 1
Explanation: 0, -1 and 1 forms a triplet
with sum equal to 0.
Example 2:
Input: n = 3, arr[] = {1, 2, 3}
Output: 0
Explanation: No triplet with zero sum exists.
Your Task:
You don't need to read input or print anything. Your task is to complete the boolean function findTriplets() which takes the array arr[] and the size of the array (n) as inputs and print 1 if the function returns true else print 0 if the function returns false.
Expected Time Complexity: O(n2)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/find-triplets-with-zero-sum/1
www.geeksforgeeks.org
Find triplets with zero sum | Practice | GeeksforGeeks
Given an array arr[] of integers, determine whether it contains a triplet whose sum equals zero. Return true if such a triplet exists, otherwise, return false.
Examples:
Input: arr[] = [0, -1, 2, -3, 1]Output: true
Explanation: The triplet [0, -
Examples:
Input: arr[] = [0, -1, 2, -3, 1]Output: true
Explanation: The triplet [0, -
π4β€2
Problem Of The Day
"Smallest Positive missing number"
You are given an array arr[] of N integers including 0. The task is to find the smallest positive number missing from the array.
Example 1:
Input:
N = 5
arr[] = {1,2,3,4,5}
Output: 6
Explanation: Smallest positive missing
number is 6.
Example 2:
Input:
N = 5
arr[] = {0,-10,1,3,-20}
Output: 2
Explanation: Smallest positive missing
number is 2.
Your Task:
The task is to complete the function missingNumber() which returns the smallest positive missing number in the array.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/smallest-positive-missing-number-1587115621/1
"Smallest Positive missing number"
You are given an array arr[] of N integers including 0. The task is to find the smallest positive number missing from the array.
Example 1:
Input:
N = 5
arr[] = {1,2,3,4,5}
Output: 6
Explanation: Smallest positive missing
number is 6.
Example 2:
Input:
N = 5
arr[] = {0,-10,1,3,-20}
Output: 2
Explanation: Smallest positive missing
number is 2.
Your Task:
The task is to complete the function missingNumber() which returns the smallest positive missing number in the array.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/smallest-positive-missing-number-1587115621/1
www.geeksforgeeks.org
Smallest Positive missing number | Practice | GeeksforGeeks
You are given an array arr[] of N integers. The task is to find the smallest positive number missing from the array.
Note: Positive number starts from 1.
Example 1:
Input:
N = 5
arr[] = {1,2,3,4,5}
Output: 6
Explanation: Smallest positive missing
nu
Note: Positive number starts from 1.
Example 1:
Input:
N = 5
arr[] = {1,2,3,4,5}
Output: 6
Explanation: Smallest positive missing
nu
Problem Of The Day
"Transpose of Matrix"
Write a program to find the transpose of a square matrix of size N*N. Transpose of a matrix is obtained by changing rows to columns and columns to rows.
Example 1:
Input:
N = 4
mat[][] = {{1, 1, 1, 1},
{2, 2, 2, 2}
{3, 3, 3, 3}
{4, 4, 4, 4}}
Output:
{{1, 2, 3, 4},
{1, 2, 3, 4}
{1, 2, 3, 4}
{1, 2, 3, 4}}
Example 2:
Input:
N = 2
mat[][] = {{1, 2},
{-9, -2}}
Output:
{{1, -9},
{2, -2}}
Your Task:
You dont need to read input or print anything. Complete the function transpose() which takes matrix[][] and N as input parameter and finds the transpose of the input matrix. You need to do this in-place. That is you need to update the original matrix with the transpose.
Expected Time Complexity: O(N * N)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/transpose-of-matrix-1587115621/1
"Transpose of Matrix"
Write a program to find the transpose of a square matrix of size N*N. Transpose of a matrix is obtained by changing rows to columns and columns to rows.
Example 1:
Input:
N = 4
mat[][] = {{1, 1, 1, 1},
{2, 2, 2, 2}
{3, 3, 3, 3}
{4, 4, 4, 4}}
Output:
{{1, 2, 3, 4},
{1, 2, 3, 4}
{1, 2, 3, 4}
{1, 2, 3, 4}}
Example 2:
Input:
N = 2
mat[][] = {{1, 2},
{-9, -2}}
Output:
{{1, -9},
{2, -2}}
Your Task:
You dont need to read input or print anything. Complete the function transpose() which takes matrix[][] and N as input parameter and finds the transpose of the input matrix. You need to do this in-place. That is you need to update the original matrix with the transpose.
Expected Time Complexity: O(N * N)
Expected Auxiliary Space: O(1)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/transpose-of-matrix-1587115621/1
practice.geeksforgeeks.org
Transpose of Matrix | Practice | GeeksforGeeks
Write a program to find the transpose of a square matrix of size N*N. Transpose of a matrix is obtained by changing rows to columns and columns to rows.Example 1:
Input:
N = 4
mat[][] = {{1, 1, 1, 1},
{2, 2, 2, 2}
Input:
N = 4
mat[][] = {{1, 1, 1, 1},
{2, 2, 2, 2}
π3
Must Learn!π‘
Cracking a college placement in one go is a tedious task but if you have the required skills and knowledge, youβll be easily able to crack it.
There are a few mistakes that students generally make in their college placements and here, weβll be talking about those problems.
In this article, weβll be talking about the 10 mistakes you should avoid during college placements.
Link- https://www.geeksforgeeks.org/common-mistakes-avoid-during-college-placements/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
Cracking a college placement in one go is a tedious task but if you have the required skills and knowledge, youβll be easily able to crack it.
There are a few mistakes that students generally make in their college placements and here, weβll be talking about those problems.
In this article, weβll be talking about the 10 mistakes you should avoid during college placements.
Link- https://www.geeksforgeeks.org/common-mistakes-avoid-during-college-placements/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
π1
π¨Job Alertπ¨
BitCot is hiring for Node JS Developer.
Location - Indore, (Madhya Pradesh)
Experience - 0 - 0.5 Years
Apply by - Aug 06, 2023
Apply via the following link and share the opportunity with your friends- https://practice.geeksforgeeks.org/jobs/bitcot-nodejsdev?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
BitCot is hiring for Node JS Developer.
Location - Indore, (Madhya Pradesh)
Experience - 0 - 0.5 Years
Apply by - Aug 06, 2023
Apply via the following link and share the opportunity with your friends- https://practice.geeksforgeeks.org/jobs/bitcot-nodejsdev?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
π1
Problem Of The Day
"Find kth element of spiral matrix"
Given a matrix with n rows and m columns. Your task is to find the kth element which is obtained while traversing the matrix spirally. You need to complete the method findK which takes four arguments the first argument is the matrix A and the next two arguments will be n and m denoting the size of the matrix A and then the forth argument is an integer k. The function will return the kth element obtained while traversing the matrix spirally.
Example 1:
Input:
n = 4, m = 4, k = 10
A[][] = {{1 2 3 4},
{5 6 7 8},
{9 10 11 12},
{13 14 15 16}}
Output:
13
Explanation:
The spiral order of matrix will look like 1->2->3->4->8->12->16->15->14->13->9->5->6->7->11->10. So the 10th element in this order is 13.
Example 2:
Input:
n = 3, m = 3, k = 4
A[][] = {{1 2 3},
{4 5 6},
{7 8 9}}
Output:
6
Explanation:
The spiral order of matrix will look like 1->2->3->6->9->8->7->4->5. So the 4th element in this order is 6.
Your Task:
You only need to implement the given function findK(). Do not read input, instead use the arguments given in the function. Return the K'th element obtained by traversing matrix spirally.
Expected Time Complexity: O(n*m)
Expected Auxiliary Space: O(n*m)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/find-nth-element-of-spiral-matrix/1
"Find kth element of spiral matrix"
Given a matrix with n rows and m columns. Your task is to find the kth element which is obtained while traversing the matrix spirally. You need to complete the method findK which takes four arguments the first argument is the matrix A and the next two arguments will be n and m denoting the size of the matrix A and then the forth argument is an integer k. The function will return the kth element obtained while traversing the matrix spirally.
Example 1:
Input:
n = 4, m = 4, k = 10
A[][] = {{1 2 3 4},
{5 6 7 8},
{9 10 11 12},
{13 14 15 16}}
Output:
13
Explanation:
The spiral order of matrix will look like 1->2->3->4->8->12->16->15->14->13->9->5->6->7->11->10. So the 10th element in this order is 13.
Example 2:
Input:
n = 3, m = 3, k = 4
A[][] = {{1 2 3},
{4 5 6},
{7 8 9}}
Output:
6
Explanation:
The spiral order of matrix will look like 1->2->3->6->9->8->7->4->5. So the 4th element in this order is 6.
Your Task:
You only need to implement the given function findK(). Do not read input, instead use the arguments given in the function. Return the K'th element obtained by traversing matrix spirally.
Expected Time Complexity: O(n*m)
Expected Auxiliary Space: O(n*m)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/find-nth-element-of-spiral-matrix/1
practice.geeksforgeeks.org
Find kth element of spiral matrix | Practice | GeeksforGeeks
Given a matrix with n rows and m columns. Your task is to find the kth element which is obtained while traversing the matrix spirally. You need to complete the method findK which takes four arguments the first argument is the matrix A and the ne
π2π₯°2
Must Learn!π‘
Are you also puzzled by these questions, donβt worry you are not alone. It is the problem of every Computer science enthusiast.
Most of the time this question arises in a studentβs mind whether to focus on Data Structures and Algorithms or perform hands-on development!!
Letβs clear this doubt today, before moving ahead to the conclusion, let us explore some essential points such as why to learn data structure?
Link- https://www.geeksforgeeks.org/how-to-manage-dsa-and-development-together/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
Are you also puzzled by these questions, donβt worry you are not alone. It is the problem of every Computer science enthusiast.
Most of the time this question arises in a studentβs mind whether to focus on Data Structures and Algorithms or perform hands-on development!!
Letβs clear this doubt today, before moving ahead to the conclusion, let us explore some essential points such as why to learn data structure?
Link- https://www.geeksforgeeks.org/how-to-manage-dsa-and-development-together/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
Looking for a change?π€ Well, we got you!ππ
We are here with Mega Job-A-Thon exclusively for experienced professionals.πΊ
Don't wait, hurry up! Register and take your next step toward your career growth.ππ
Register here: https://practice.geeksforgeeks.org/contest/mega-job-a-thon-hiring-challenge-for-experience?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=megajobathon
We are here with Mega Job-A-Thon exclusively for experienced professionals.πΊ
Don't wait, hurry up! Register and take your next step toward your career growth.ππ
Register here: https://practice.geeksforgeeks.org/contest/mega-job-a-thon-hiring-challenge-for-experience?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=megajobathon
Problem Of The Day
"Power Of Numbers"
Given a number and its reverse. Find that number raised to the power of its own reverse.
Note: As answers can be very large, print the result modulo 109 + 7.
Example 1:
Input:
N = 2
Output: 4
Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000000007.
Example 2:
Input:
N = 12
Output: 864354781
Explanation: The reverse of 12 is 21and 1221 when divided by 1000000007 gives remainder as 864354781.
Your Task:
You don't need to read input or print anything. You just need to complete the function pow() that takes two parameters N and R denoting the input number and its reverse and returns power of (N to R)mod(109 + 7).
Expected Time Complexity: O(LogN).
Expected Auxiliary Space: O(LogN).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/power-of-numbers-1587115620/1
"Power Of Numbers"
Given a number and its reverse. Find that number raised to the power of its own reverse.
Note: As answers can be very large, print the result modulo 109 + 7.
Example 1:
Input:
N = 2
Output: 4
Explanation: The reverse of 2 is 2 and after raising power of 2 by 2 we get 4 which gives remainder as 4 when divided by 1000000007.
Example 2:
Input:
N = 12
Output: 864354781
Explanation: The reverse of 12 is 21and 1221 when divided by 1000000007 gives remainder as 864354781.
Your Task:
You don't need to read input or print anything. You just need to complete the function pow() that takes two parameters N and R denoting the input number and its reverse and returns power of (N to R)mod(109 + 7).
Expected Time Complexity: O(LogN).
Expected Auxiliary Space: O(LogN).
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/power-of-numbers-1587115620/1
practice.geeksforgeeks.org
Power Of Numbers | Practice | GeeksforGeeks
Given a number and its reverse. Find that number raised to the power of its own reverse.Note: As answers can be very large, print the result modulo 109 + 7.
Example 1:
Input:
N = 2, R = 2
Output: 4
Explanation: The reverse of 2 is 2 and after raising
Example 1:
Input:
N = 2, R = 2
Output: 4
Explanation: The reverse of 2 is 2 and after raising
π3
Must Learn!π‘
In React.js, you can create components that are very helpful for developers to reuse them.
Since React.js is component-based and uses Virtual DOM, it will make the Web Applications faster, and easy to scalable. But before learning React.js, it is very essential to have a good understanding of JavaScript, HTML, and CSS.
So, in this article, we will see some JavaScript concepts that everyone should know before learning React.js. Give it a read.
Link- https://www.geeksforgeeks.org/top-javascript-concepts-to-know-before-learning-react/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
In React.js, you can create components that are very helpful for developers to reuse them.
Since React.js is component-based and uses Virtual DOM, it will make the Web Applications faster, and easy to scalable. But before learning React.js, it is very essential to have a good understanding of JavaScript, HTML, and CSS.
So, in this article, we will see some JavaScript concepts that everyone should know before learning React.js. Give it a read.
Link- https://www.geeksforgeeks.org/top-javascript-concepts-to-know-before-learning-react/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
GeeksforGeeks
Mega Job-A-Thon for Experienced Professionals.pdf
These are the opportunities, we bet you don't wanna miss! It's time for you to boost your career!ππ
We are here with Mega Job-A-Thon exclusively for experienced professionals.πΊ
Don't wait, hurry up! Register and take your next step toward your career growth.ππ
Register here:
UKG-
Senior Software Engineer - https://bit.ly/43lRO0z
Lead Software Engineer - https://bit.ly/44oUuvS
Principal Software Engineer - https://bit.ly/3OccIez
Lead QA Engineer - https://bit.ly/3JUl6N5
Lead Site Reliability Engineer - https://bit.ly/46HKJdR
Senior DevOps Engineer - https://bit.ly/3XM6Z1U
Lead Devops Engineer" - https://bit.ly/3PRHo5O
Datazoic -
Product Software Engineer - https://bit.ly/3pMZFa0
Javascript Developer - https://bit.ly/46LbEoT
Mega Job-A-Thon details here-
https://practice.geeksforgeeks.org/contest/mega-job-a-thon-hiring-challenge-for-experience?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=megajobathon
We are here with Mega Job-A-Thon exclusively for experienced professionals.πΊ
Don't wait, hurry up! Register and take your next step toward your career growth.ππ
Register here:
UKG-
Senior Software Engineer - https://bit.ly/43lRO0z
Lead Software Engineer - https://bit.ly/44oUuvS
Principal Software Engineer - https://bit.ly/3OccIez
Lead QA Engineer - https://bit.ly/3JUl6N5
Lead Site Reliability Engineer - https://bit.ly/46HKJdR
Senior DevOps Engineer - https://bit.ly/3XM6Z1U
Lead Devops Engineer" - https://bit.ly/3PRHo5O
Datazoic -
Product Software Engineer - https://bit.ly/3pMZFa0
Javascript Developer - https://bit.ly/46LbEoT
Mega Job-A-Thon details here-
https://practice.geeksforgeeks.org/contest/mega-job-a-thon-hiring-challenge-for-experience?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=megajobathon
practice.geeksforgeeks.org
GFG Get Hired | UKG | Mega Job-A-Thon
Get Hired with GFG. Explore job opportunities and participate in hiring challenges.
Problem Of The Day
"Unique Number of Occurrences"
Given an array arr of N integers, the task is to check whether the frequency of the elements in the array is unique or not. Or in other words, there are no two distinct numbers in array with equal frequency. If all the frequency is unique then return true, else return false.
Example 1:
Input:
N = 5
arr = [1, 1, 2, 5, 5]
Output:
false
Explanation:
The array contains 2 (1βs), 1 (2βs) and 2 (5βs), since the number of frequency of 1 and 5 are the same i.e. 2 times. Therefore, this array does not satisfy the condition.
Example 2:
Input:
N = 10
arr = [2, 2, 5, 10, 1, 2, 10, 5, 10, 2]
Output:
true
Explanation:
Number of 1βs -> 1
Number of 2βs -> 4
Number of 5βs -> 2
Number of 10βs -> 3.
Since, the number of occurrences of elements present in the array is unique. Therefore, this array satisfy the condition.
Your task:
You don't need to read input or print anything. Your task is to complete the function isFrequencyUnique() which take integer N and array arr of size N as arguments, and returns a boolean.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/unique-frequencies-of-not/1
"Unique Number of Occurrences"
Given an array arr of N integers, the task is to check whether the frequency of the elements in the array is unique or not. Or in other words, there are no two distinct numbers in array with equal frequency. If all the frequency is unique then return true, else return false.
Example 1:
Input:
N = 5
arr = [1, 1, 2, 5, 5]
Output:
false
Explanation:
The array contains 2 (1βs), 1 (2βs) and 2 (5βs), since the number of frequency of 1 and 5 are the same i.e. 2 times. Therefore, this array does not satisfy the condition.
Example 2:
Input:
N = 10
arr = [2, 2, 5, 10, 1, 2, 10, 5, 10, 2]
Output:
true
Explanation:
Number of 1βs -> 1
Number of 2βs -> 4
Number of 5βs -> 2
Number of 10βs -> 3.
Since, the number of occurrences of elements present in the array is unique. Therefore, this array satisfy the condition.
Your task:
You don't need to read input or print anything. Your task is to complete the function isFrequencyUnique() which take integer N and array arr of size N as arguments, and returns a boolean.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/unique-frequencies-of-not/1
practice.geeksforgeeks.org
Unique Number of Occurrences | Practice | GeeksforGeeks
Given an array arr of N integers, the task is to check whether the frequency of the elements in the array is unique or not. Or in other words, there are no two distinct numbers in array with equal frequency. If all the frequency is unique then return
π2β€1
Must Learn!π‘
The power of AI is typically compared with the power of the human brain, but what can be a better trend is to use AI to be better with the brain.
Designer or engineer AI canβt replace them because there are multiple scenarios where AI wonβt be able to perform, think or produce optimal solutions as compared to what we humans can do.
In this article letβs focus on how and where all places in the design process can use the power of AI β The ChatGPT tool to help us get better at design and produce more optimal solutions.
Link- https://www.geeksforgeeks.org/chatgpt-prompts-for-ui-ux-designers/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
The power of AI is typically compared with the power of the human brain, but what can be a better trend is to use AI to be better with the brain.
Designer or engineer AI canβt replace them because there are multiple scenarios where AI wonβt be able to perform, think or produce optimal solutions as compared to what we humans can do.
In this article letβs focus on how and where all places in the design process can use the power of AI β The ChatGPT tool to help us get better at design and produce more optimal solutions.
Link- https://www.geeksforgeeks.org/chatgpt-prompts-for-ui-ux-designers/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
π1
GeeksforGeeks
Mega Job A Thon Job Post.pdf
Wanna upgrade your career? Looking for the best opportunities? Don't worry! We are here... π π
This time Mega Job-A-Thon is exclusively for experienced professionals. πΊ
Don't wait, hurry up! Register and take your next step toward your career growth. π π
Register here:
Mtalkz - https://bit.ly/3PSOdnK
Alphaware - https://bit.ly/43mhqe0
Epam India - https://bit.ly/3PPCsyt
Zopper - https://bit.ly/3PQSeZZ
Tata 1MG - https://bit.ly/3JVoPd7
Tata 1MG - https://bit.ly/3Q09yvL
Tata 1MG - https://bit.ly/3JUNZIW
Mega Job-A-Thon details here- https://practice.geeksforgeeks.org/contest/mega-job-a-thon-hiring-challenge-for-experience?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=megajobathon
This time Mega Job-A-Thon is exclusively for experienced professionals. πΊ
Don't wait, hurry up! Register and take your next step toward your career growth. π π
Register here:
Mtalkz - https://bit.ly/3PSOdnK
Alphaware - https://bit.ly/43mhqe0
Epam India - https://bit.ly/3PPCsyt
Zopper - https://bit.ly/3PQSeZZ
Tata 1MG - https://bit.ly/3JVoPd7
Tata 1MG - https://bit.ly/3Q09yvL
Tata 1MG - https://bit.ly/3JUNZIW
Mega Job-A-Thon details here- https://practice.geeksforgeeks.org/contest/mega-job-a-thon-hiring-challenge-for-experience?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=megajobathon
practice.geeksforgeeks.org
GFG Get Hired | Mtalkz | Mega Job-A-Thon
Get Hired with GFG. Explore job opportunities and participate in hiring challenges.
π2
Problem Of The Day
"Implement two stacks in an array"
Your task is to implement 2 stacks in one array efficiently. You need to implement 4 methods.
push1 : pushes element into first stack.
push2 : pushes element into second stack.
pop1 : pops element from first stack and returns the popped element. If first stack is empty, it should return -1.
pop2 : pops element from second stack and returns the popped element. If second stack is empty, it should return -1.
Example 1:
Input:
push1(2)
push1(3)
push2(4)
pop1()
pop2()
pop2()
Output:
3 4 -1
Explanation:
push1(2) the stack1 will be {2}
push1(3) the stack1 will be {2,3}
push2(4) the stack2 will be {4}
pop1() the poped element will be 3 from stack1 and stack1 will be {2}
pop2() the poped element will be 4 from stack2 and now stack2 is empty
pop2() the stack2 is now empty hence returned -1.
Example 2:
Input:
push1(1)
push2(2)
pop1()
push1(3)
pop1()
pop1()
Output:
3 1 -1
Explanation:
push1(1) the stack1 will be {1}
push2(2) the stack2 will be {2}
pop1() the poped element will be 1 from stack1 and stack1 will be empty
push1(3) the stack1 will be {3}
pop1() the poped element will be 3 from stack1 and stack1 will be empty
pop1() the stack1 is now empty hence returned -1.
Your Task:
You don't need to read input or print anything. You are required to complete the 4 methods push1, push2 which takes one argument an integer 'x' to be pushed into stack one and two and pop1, pop2 which returns the integer poped out from stack one and two. If no integer is present in the stack return -1.
Expected Time Complexity: O(1) for all the four methods.
Expected Auxiliary Space: O(1) for all the four methods.
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/implement-two-stacks-in-an-array/1
"Implement two stacks in an array"
Your task is to implement 2 stacks in one array efficiently. You need to implement 4 methods.
push1 : pushes element into first stack.
push2 : pushes element into second stack.
pop1 : pops element from first stack and returns the popped element. If first stack is empty, it should return -1.
pop2 : pops element from second stack and returns the popped element. If second stack is empty, it should return -1.
Example 1:
Input:
push1(2)
push1(3)
push2(4)
pop1()
pop2()
pop2()
Output:
3 4 -1
Explanation:
push1(2) the stack1 will be {2}
push1(3) the stack1 will be {2,3}
push2(4) the stack2 will be {4}
pop1() the poped element will be 3 from stack1 and stack1 will be {2}
pop2() the poped element will be 4 from stack2 and now stack2 is empty
pop2() the stack2 is now empty hence returned -1.
Example 2:
Input:
push1(1)
push2(2)
pop1()
push1(3)
pop1()
pop1()
Output:
3 1 -1
Explanation:
push1(1) the stack1 will be {1}
push2(2) the stack2 will be {2}
pop1() the poped element will be 1 from stack1 and stack1 will be empty
push1(3) the stack1 will be {3}
pop1() the poped element will be 3 from stack1 and stack1 will be empty
pop1() the stack1 is now empty hence returned -1.
Your Task:
You don't need to read input or print anything. You are required to complete the 4 methods push1, push2 which takes one argument an integer 'x' to be pushed into stack one and two and pop1, pop2 which returns the integer poped out from stack one and two. If no integer is present in the stack return -1.
Expected Time Complexity: O(1) for all the four methods.
Expected Auxiliary Space: O(1) for all the four methods.
Solve and submit your answer here : https://practice.geeksforgeeks.org/problems/implement-two-stacks-in-an-array/1
www.geeksforgeeks.org
Two Stacks in an Array | Practice | GeeksforGeeks
You are given an array of a fixed size. Your task is to efficiently implement two stacks in this single array.
The following operations must be supported:
(i) twoStacks : Initialize the data structures and variables to be used to implement  
The following operations must be supported:
(i) twoStacks : Initialize the data structures and variables to be used to implement  
π3
Must Learn!π‘
QuillBot has you covered whether youβre a student aiming for academic success, a professional looking for polished and compelling communication, or a creative person looking for new ideas.
This paraphrasing tool offers intelligent assistance that improves your writing abilities and efficiency, from paraphrasing to summarising, grammar checking to vocabulary building.
Link- https://www.geeksforgeeks.org/quillbot-ai-paraphrasing-writing-tool/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
QuillBot has you covered whether youβre a student aiming for academic success, a professional looking for polished and compelling communication, or a creative person looking for new ideas.
This paraphrasing tool offers intelligent assistance that improves your writing abilities and efficiency, from paraphrasing to summarising, grammar checking to vocabulary building.
Link- https://www.geeksforgeeks.org/quillbot-ai-paraphrasing-writing-tool/?utm_source=telegram&utm_medium=marketingteam_gfgmain&utm_campaign=github
π2