Function to return the maximum profit
static int maxProfit ( int n , int k , int prices [ ] ) { int ans = 0 , buy = 0 , sell = 0 ; Stack < int [ ] > transaction = new Stack < > ( ) ; PriorityQueue < Integer > profits = new PriorityQueue < > ( ) ; while ( sell < n ) { buy = sell ;