Assignment
Assignment
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:
Java
Output:
package Java_Assignment;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
Integer high =
letters.values().stream().sorted(Comparator.reverseOrder()).findFirst().get();
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
package Java_Assignment;
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
5 1 4 3
Sample Output:
Output
package Java_Assignment;
import java.util.Arrays;
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
3 2 1 3
Sample Output:
2
Output
package Java_Assignment;
import java.util.ArrayList;
import java.util.List;
nameList.stream().distinct().forEach(System.out::print);
}