human
Minimum salary hike for each employee such that no employee feels unfair | Python Program to find the minimum hike of each employee such that no adjacent employee feels unfair.
As hikes are positive integers , keeping minimum value.
Pass - 1 : compare with previous employee.
Pass - 2 : compare with Next employee.
Driver Code.
Function Call.
result -> [ 2 , 1 , 3 , 2 , 1 , 2 ].
Function Call.
result -> [ 1 , 2 , 3 , 1 ].
Function Call.
result -> [ 1 , 2 ]"
How can the above be solved in Python?
assistant
#Here is code to minimum salary hike for each employee such that no employee feels unfair and the other steps required.
 def findMinimumHike ( ratings , employees ) :
	hikes = [ 1 for i in range ( employees ) ]
	for i in range ( 1 , employees ) :
		if ( ratings [ i - 1 ] < ratings [ i ] and hikes [ i - 1 ] >= hikes [ i ] ) :
			hikes [ i ] = hikes [ i - 1 ] + 1 ;
	for i in range ( employees - 2 , - 1 , - 1 ) :
		if ( ratings [ i ] > ratings [ i + 1 ] and hikes [ i + 1 ] >= hikes [ i ] ) :
			hikes [ i ] = hikes [ i + 1 ] + 1 ;
	return hikes
data = [ 5 , 3 , 4 , 2 , 1 , 6 ]
result = findMinimumHike ( data , len ( data ) )
print ( result )
data = [ 1 , 3 , 5 , 4 ]
result = findMinimumHike ( data , len ( data ) )
print ( result )
data = [ 1 , 4 ]
result = findMinimumHike ( data , len ( data ) )
print ( result )