Suppose there is a trend dictionary with a string representing a date (mm-dd-yyyy) as a key and as a value a set of tags (hashtags) that were trends on Twitter for that date. For example:
trends = {'08 -22-2016 ': {' # Rio2016 ',' #BSC ',' #ECU '}, '08 -25-2016 ': {' # GYE ',' #BRA '}, ..., '08 -27- 2016': {'# YoSoyEspol', '#GYE', '#BSC'}}
Implement:
a) report Trends (trends, date list) that the trend dictionary receives and a list with strings that represent dates (mm-dd-yyyy). The function should show on screen:
- 1) The labels that were trending all dates in the Date list
- 2) The labels that were trending at least on one of the dates in the Date list
public static void reportaTendencias(HashMap<String, LinkedList<String>>
m, LinkedList<String> l) {
for (String clave : m.keySet()) {
for (String valor : m.get(clave)) {
System.out.println("fecha: " + clave + "," + "etiquetas: " + valor);
}
}
}
I did this for literal 1 and it works but I do not know if it's efficient and 2 I'm not sure how to do it.
b) Excluding trends (trends, date1, date2) that the trend dictionary receives and two strings that represent dates (mm-dd-yyyy). The function should show the labels on the screen which were trends or on date1 or date2, but not both. Note: suppose that date1 and date2 exist in the dictionary as keys.
public static void tendenciasExcluyentes(HashMap<String,
LinkedList<String>> m, String fecha1, String fecha2) {
LinkedList<String> lista = new LinkedList();
if (m.containsKey(fecha1)) {
System.out.println(m.get(fecha1));
}
}
}
And for this I'm not sure how to continue