Minimum salary hike for each employee such that no employee feels unfair | Python3 program for the above approach ; Function that print minimum hike ; Insert INF at begin and end of array ; To store hike of each employee ; For Type 1 employee ; For Type 2 employee ; For Type 3 employee ; For Type 4 employee ; Print the min hike for each employee ; Driver Code ; Given array of rating of employees ; Function Call
INF = 1e9 NEW_LINE def findMinHike ( arr , n ) : NEW_LINE INDENT arr . insert ( 0 , INF ) NEW_LINE arr . append ( INF ) NEW_LINE hike = [ 0 ] * ( n + 2 ) NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( arr [ i - 1 ] >= arr [ i ] and arr [ i ] <= arr [ i + 1 ] ) : NEW_LINE INDENT hike [ i ] = 1 NEW_LINE DEDENT DEDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( arr [ i - 1 ] < arr [ i ] and arr [ i ] <= arr [ i + 1 ] ) : NEW_LINE INDENT hike [ i ] = hike [ i - 1 ] + 1 NEW_LINE DEDENT DEDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( arr [ i - 1 ] >= arr [ i ] and arr [ i ] > arr [ i + 1 ] ) : NEW_LINE INDENT hike [ i ] = hike [ i + 1 ] + 1 NEW_LINE DEDENT DEDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( arr [ i - 1 ] < arr [ i ] and arr [ i ] > arr [ i + 1 ] ) : NEW_LINE INDENT hike [ i ] = max ( hike [ i - 1 ] , hike [ i + 1 ] ) + 1 NEW_LINE DEDENT DEDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT print ( hike [ i ] , end = " ▁ " ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 5 , 3 , 4 , 2 , 1 , 6 ] NEW_LINE findMinHike ( arr , len ( arr ) ) NEW_LINE DEDENT