Input Format:
The first line of the input consists of an integer – N, representing the total number of apples that Josh wants to buy.
The second line consists of two space-separated positive integers – M1 and P1, representing the number of apples in a lot and the lot’s price at shop A, respectively.
The third line consists of two space-separated positive integers-M2 and P2, representing the number of apples in a lot’s price at shop B, respectively.
Output Format:
Print a positive integer representing the minimum price at which Josh can buy the apples.
Sample Input:
19
3 10
4 15
Sample Output:
65
Wipro Elite NTH Coding Questions #2
Write a program to implement a bubble sort algorithm for sorting the elements of an array.
Input Format:
The first line corresponds to the size of an array.
The second line corresponds to the elements.
Output Format:
Print the element in ascending order.
Sample Input:
6
11 15 26 38 9 10
Sample Output:
9 10 11 15 26 38
Wipro Elite NTH Coding Questions #3
You are playing an online game. In the game, a list of N numbers is given. The player has to arrange the numbers so that all the odd numbers of the list come after the even numbers. Write an algorithm to arrange the given list such that all the odd numbers of the list come after the even numbers.
Input
The first line of the input consists of an integer num, representing the size of the list(N). The second line of the input consists of N space-separated integers representing the values of the list
Output
Print N space-separated integers such that all the odd numbers of the list come after the even numbers
Example
Sample Input
8
10 98 3 33 12 22 21 11
Sample Output
10 98 12 22 3 33 21 11
Wipro Elite NTH Coding Questions #4
A digital machine generates binary data which consists of a string of 0s and 1s. A maximum signal M, in the data, consists of the maximum number of either 1s or 0s appearing consecutively in the data but M can’t be at the beginning or end of the string. Design a way to find the length of the maximum signal.
Input
The first line of the input consists of an integer N, representing the length of the binary string. The second line consists of a string of length N consisting of 0s and 1s only.
Output
Print an integer representing the length of the maximum signal.
Example
Example 1:
Input
6
101000
Output
1
Explanation
For 101000, M can be 0 at the second index or at the third index so in both cases max length = 1.
Example2:
Input
9
101111110
Output
6