Question 1 : Design a customer preference system for a video streaming company.
Answer : I gave below design image in next 45 minutes along with some queries for such client to understand more about this
requirement-
Answer : I gave below design image in next 45 minutes along with some queries for such client to understand more about this
requirement-
Question 2 : Develop a program called VowelCounter. It should take a sentence as an input and should output the top 3
words having most number of vowels(a, e, I, o, or u).
Answer : As shown in below image -
words having most number of vowels(a, e, I, o, or u).
Answer : As shown in below image -
Improvements :
a) Create instance of VowelCounter once & use that in the loop.
b) Better make push() as static.
c) Rather converting to lower & upper case each character everytime, add both lower & upper case vowels in the set 'vowels'.
d) Using Java8, we can have printTop3() method like shown in below image -
a) Create instance of VowelCounter once & use that in the loop.
b) Better make push() as static.
c) Rather converting to lower & upper case each character everytime, add both lower & upper case vowels in the set 'vowels'.
d) Using Java8, we can have printTop3() method like shown in below image -
Below is another variation around the Predicate used above, now below I am using predicate for characters not for integers -
A bit improved version is given below.
Points to note here -
1) Code is concise & more readable, requiring no extra push().
2) Avoiding the usage of type casting to char.
3) To keep the size of priorityqueue fixed, doing sorting twice - Once to sort priority queue in increasing order to pop out the
the lower values & then copying gits elements in List to sort it in decreasing order.
4) If you don't need the results in decreasing order then creating list & sorting in decreasing order can be avoided.
Points to note here -
1) Code is concise & more readable, requiring no extra push().
2) Avoiding the usage of type casting to char.
3) To keep the size of priorityqueue fixed, doing sorting twice - Once to sort priority queue in increasing order to pop out the
the lower values & then copying gits elements in List to sort it in decreasing order.
4) If you don't need the results in decreasing order then creating list & sorting in decreasing order can be avoided.