an HCL GUVI product

21. Max Profit with 2 Transactions

Required Input:

prices = [3,3,5,0,0,3,1,4]

Expected Output:

6

Code In Python

def max_profit_two_transactions(prices): # Write your code here pass # Prefilled input prices = [3,3,5,0,0,3,1,4] print(max_profit_two_transactions(prices))

Run Code?

Click Run Button to view compiled output

22. Minimize Max Height Difference

Required Input:

heights = [1, 5, 8, 10], k = 2

Expected Output:

5

Code In Python

def minimize_height_diff(heights, k): # Write your code here pass # Prefilled input heights = [1, 5, 8, 10] k = 2 print(minimize_height_diff(heights, k))

Run Code?

Click Run Button to view compiled output

23. Circular Gas Tour Start Point

Required Input:

fuel = [4,6,7,4], dist = [6,5,3,5]

Expected Output:

1

Code In Python

def can_complete_circular_tour(fuel, dist): # Write your code here pass fuel = [4, 6, 7, 4] dist = [6, 5, 3, 5] print(can_complete_circular_tour(fuel, dist))

Run Code?

Click Run Button to view compiled output

24. Distribute Jobs with Min Max Load

Required Input:

jobs = [3,2,3], k = 2

Expected Output:

5

Code In Python

def minimum_workload(jobs, k): # Write your code here pass jobs = [3, 2, 3] k = 2 print(minimum_workload(jobs, k))

Run Code?

Click Run Button to view compiled output

25. Min Cost to Cut a Rod

Required Input:

length = 7, cuts = [1,3,4,5]

Expected Output:

16

Code In Python

def min_cost_to_cut(length, cuts): # Write your code here pass length = 7 cuts = [1, 3, 4, 5] print(min_cost_to_cut(length, cuts))

Run Code?

Click Run Button to view compiled output

3 of 3