Greedy algorithms are a class of algorithms that make locally optimal choices at each step with the hope of finding a global optimum solution.
At every step of the algorithm, we make a choice that looks the best at the moment. To make the choice, we sometimes sort the array so that we can always get the next optimal choice quickly. We sometimes also use a priority queue to get the next optimal item.
After making a choice, we check for constraints (if there are any) and keep picking until we find the solution.
Greedy algorithms do not always give the best solution. For example, in coin change and 0/1 knapsack problems, we get the best solution using Dynamic Programming.