0% found this document useful (0 votes)
47 views

Java Questions

This document contains 4 questions about programming problems. Question 1 asks to remove duplicate characters from a string like "Java" to output "Jav". Question 2 asks to determine the most frequent flower type in a string like "babcabbcaab" to output "b". Question 3 asks to determine the next brightest candle in an array like [5,1,4,3] to output 3. Question 4 asks to count the number of tallest candles in an array like [3,2,1,3] to output 2.

Uploaded by

Vignesh Vicky
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Java Questions

This document contains 4 questions about programming problems. Question 1 asks to remove duplicate characters from a string like "Java" to output "Jav". Question 2 asks to determine the most frequent flower type in a string like "babcabbcaab" to output "b". Question 3 asks to determine the next brightest candle in an array like [5,1,4,3] to output 3. Question 4 asks to count the number of tallest candles in an array like [3,2,1,3] to output 2.

Uploaded by

Vignesh Vicky
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

Question:1

Write a program to remove all the duplicate characters from a given input String,
like, if the given String is "Java" then the output should be "Jav". The second or
further occurrence of duplicates should be removed.

Sample Input:
Java
Sample Output:
Jav

Question:2
Ananya loves flowers and today it's her birthday. Her best friend Ayushi wants to
present her bag full of flowers. The bag can contain only one type of flower.
Ayushi has a bunch of flowers in her garden, but due to the restriction of the bag,
she can pick flowers of only one kind.
Ayushi is now confused which type of flowers to pick. So she decides to pick the
flowers which has maximum occurence in her garden. Your task is to help her in
deciding the type of flower she should pick.

Sample Input :
babcabbcaab
Sample Output:
b

Question:3
Pranav goes to a shop to buy candles. The shopkeeper shows him candles of
different brightness level. As Pranav hates light, he wants to buy a candle with the
minimum brightness. But his wife instructed him not to do so.
Now Pranav has to buy a candle which is just brighter than the minimum one. Can
you help him in choosing the right candle.

Sample Input:
4
5143
Sample Output:
3
Question:4
You are in charge of the cake for a child's birthday. You have decided the cake will
have one candle for each year of their total age. They will only be able to blow out
the tallest of the candles. Count how many candles are tallest.
Example:
candle = [4,4,1,3]
The maximum height candles are 4 units high. There are 2 of them, so return 2.
Sample Input:
4
3213
Sample Output:
2

You might also like