Tip 1 : Do practise coding
Tip 2 : revise all the concepts
Tip 1 : Keep it to one page
Tip 2 : Add any one good project
If the given input string is "Welcome to Coding Ninjas", then you should return "Ninjas Coding to Welcome" as the reversed string has only a single space between two words and there is no leading or trailing space.
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]
If we are given a string ‘aabb’.Then we can see the frequency of a=2 and b=2. The position of ‘a’ in alphabets is 1 and the position of ‘b’ is 2. So ‘a’ has an even frequency but its position is odd, so it will not contribute to M. As ‘b’ has an even frequency and its position is also even, so M=1. Now M =1 which is odd, so we have to return “ODD”.
Let’s consider the equation X^2 + 2X + 1 = 0 . We can see that the quadratic equation has no real roots. So we return a pair of -1 i.e. [-1, -1].
1. If the equation has repeated roots, return the roots twice.
2. If there are imaginary roots, return -1 twice.
3. If the root is not an integer, return the greatest integer value less
than the root.
What is a structure in C?
What are the differences between union and structure?
Why do we use structure when union takes less memory?
What is structure padding?
Write a program to reverse a linked list without recursion.
Tell me about yourself.
Discussion on projects.
Why should we hire you?
Tip 1 : Stay Confident
Tip 2 : Be polite
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is a constructor in Java?