emory-courses / dsa-java

Data Structures and Algorithms in Java
https://emory.gitbook.io/dsa-java/
42 stars 55 forks source link

[HW#2] extracredit use of Map #147

Closed caroltang0331 closed 3 years ago

caroltang0331 commented 3 years ago

one of the notes says we cannot use Map to store candidate. Is there a recommend data structure to keep track of the picked candidate and the frequency they are pick? I originally stored the picked candidate and frequency in a map and sort it based on the frequency, so i guess maybe a 2D array works too? but im just a little confused, can i get a hint on how to keep track of the frequency

lujiaying commented 3 years ago

so i guess maybe a 2D array works too?

Yes. As long as not using map, feel free to use any data structures. Even using a designed string encoding schema could lead to an alternative way of storing <key, freq>.

Is there a recommend data structure to keep track of the picked candidate and the frequency they are pick?

This is directly related to the final solution. So I would not give explicit hint.