Tip 1 : Prepare basics of any language
Tip 2 : Practice at least 5 questions on every topic
Tip 1 : Resume should be updated.
Tip 2 : Should have 1 or 2 projects
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.
This is a visualization of the Circular Linked List, represented by:
1 2 3 4 5 -1
The Circular Linked List before/after deletion may happen to be empty. In that case, only print -1.
All integers in the list are unique.
a) Duplicate elements may be present.
b) If no such element is present return -1.
Input: Given a sequence of five numbers 2, 4, 5, 6, 8.
Output: 6
Explanation:
In the given sequence of numbers, number 8 is the largest element, followed by number 6 which is the second-largest element. Hence we return number 6 which is the second-largest element in the sequence.
I have set 2 variables largest and secondLargest .Then iterated list with for loop and compare ith element with largest and secondLargest and changed them accordingly. Finally returned secondLargest.
I took a dictionary and stored occurence of every elements from list. Then took a list as ans and iterated given list and checked if its occurence is 1 with dictionary if occurence is 1, then add that element in ans. Finally return ans list.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you write a single-line comment in C++?