Tip 1: Engage in Regular Coding Practice Sessions.
Tip 2: Create Real-World Projects to Apply Knowledge Effectively.
Tip 1: Enhance your resume with relevant experiences that demonstrate your skills.
Tip 2: Include impressive and impactful projects that showcase your abilities effectively.



All the elements in the array are distinct.
Input: arr = [3,4,5,1,2]
Output: 1
Explanation: The original array was [1,2,3,4,5] and it was rotated 3 times.






Let the array 'ARR' be [1, 2, 3] and 'B' = 5. Then all possible valid combinations are-
(1, 1, 1, 1, 1)
(1, 1, 1, 2)
(1, 1, 3)
(1, 2, 2)
(2, 3)
int mod=1e9+7;
int dp [1001] [1001];
int solve(int a, int b,int cnt1,int cnt2,int mx, int mn)
{
int len=a*cnt1+b*cnt2;
if (len>mx)
return 0;
if(dp [cnt1] [cnt2]!=-1)
return dp[cnt1] [cnt2];
int ans=(len>=mn)?1:0;
int ans1=solve (a,b, cnt1+1, cnt2,mx, mn)%mod;
int ans2=solve(a,b, cnt1, cnt2+1, mx,mn )%mod;
ans=(ans+ans2+ans1)%mod;
return dp [cnt1][cnt2]=ans;
}
int StartupNames (int minLength, int maxLength, int cntone, int cntTwo){
memset (dp,-1, sizeof (dp));
return solve (cntOne, cntTwo, 0, 0, maxLength, minLength) ;
}






1. Constructor:
It initializes the data members(queues) as required.
2. push(data) :
This function should take one argument of type integer. It pushes the element into the stack and returns nothing.
3. pop() :
It pops the element from the top of the stack and, in turn, returns the element being popped or deleted. In case the stack is empty, it returns -1.
4. top :
It returns the element being kept at the top of the stack. In case the stack is empty, it returns -1.
5. size() :
It returns the size of the stack at any given instance of time.
6. isEmpty() :
It returns a boolean value indicating whether the stack is empty or not.
Query-1(Denoted by an integer 1): Pushes an integer data to the stack. (push function)
Query-2(Denoted by an integer 2): Pops the data kept at the top of the stack and returns it to the caller. (pop function)
Query-3(Denoted by an integer 3): Fetches and returns the data being kept at the top of the stack but doesn't remove it, unlike the pop function. (top function)
Query-4(Denoted by an integer 4): Returns the current size of the stack. (size function)
Query-5(Denoted by an integer 5): Returns a boolean value denoting whether the stack is empty or not. (isEmpty function)
Operations:
1 5
1 10
2
3
4
Enqueue operation 1 5: We insert 5 at the back of the queue.
Queue: [5]
Enqueue operation 1 10: We insert 10 at the back of the queue.
Queue: [5, 10]
Dequeue operation 2: We remove the element from the front of the queue, which is 5, and print it.
Output: 5
Queue: [10]
Peek operation 3: We return the element present at the front of the queue, which is 10, without removing it.
Output: 10
Queue: [10]
IsEmpty operation 4: We check if the queue is empty.
Output: False
Queue: [10]
#include
#include
using namespace std;
queueq1;
queueq2;
void pushElement(int x,int size)
{
if(size==q1.size())
{
cout<<"Stack is Full"<>size;
while(n!=-1)
{
cout<<"Enter Your choice"<>n;
if(n==1)
{
int x;
cin>>x;
pushElement(x,size);
}
else if(n==2)
{
int temp=topElement();
if(temp==-1)
cout<<"Stack is empty"< else
cout<<"Top element is "< }
else if(n==3)
{
popElement();
}
else if(n==4)
{
printStack();
}
else break;
}
return 0;
}


1. Push(num): Push the given number in the stack.
2. Pop: Remove and return the top element from the stack if present, else return -1.
3. Top: return the top element of the stack if present, else return -1.
4. getMin: Returns minimum element of the stack if present, else return -1.
For the following input:
1
5
1 1
1 2
4
2
3
For the first two operations, we will just insert 1 and then 2 into the stack which was empty earlier. So now the stack is => [2,1]
In the third operation, we need to return the minimum element of the stack, i.e., 1. So now the stack is => [2,1]
For the fourth operation, we need to pop the topmost element of the stack, i.e., 2. Now the stack is => [1]
In the fifth operation, we return the top element of the stack, i.e. 1 as it has one element. Now the stack is => [1]
So, the final output will be:
1 2 1
class MinStack {
public:
stack>s;
MinStack() {
}
void push(int val) {
if(s.size()==0)
{
s.push({val,val});
}
else
{
auto x=s.top();
if(x.second {
s.push({val,x.second});
}
else
{
s.push({val,val});
}
}
}
void pop() {
if(s.size()==0)
return ;
else
s.pop();
}
int top() {
return s.top().first;
}
int getMin() {
return s.top().second;
}
};



Each product can cross the integer limits, so we should take modulo of the operation.
Take MOD = 10^9 + 7 to always stay in the limits.
Can you try solving the problem in O(1) space?
class Solution {
public:
vector productExceptSelf(vector& arr) {
int n=arr.size();
vectorleft(n,1);
for(int i=0;i=0;i--)
{
int k=temp;
temp*=arr[i];
if(i==0)
arr[i]=k;
else if(i==n-1)
arr[i]=left[i-1];
else{
arr[i]=k*left[i-1];
}
}
return arr;
}
};

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is recursion?