sum to keep track of the sum of positive beauty values.res to store the maximum beauty of the garden, initially set to Integer.MIN_VALUE.flowers array:
a. If the current flower's beauty value is in the HashMap, calculate the potential maximum beauty and update res if it's greater.
b. If the flower's beauty value is positive, add it to sum.
c. If the flower's beauty value is not in the HashMap, add it along with the current sum.res as the maximum possible beauty of the garden.