Return the total cost if gain < 0 return (gain * -1); } // Driver code public static void main(String[] args) { int cost[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; String str = "geeksforgeeks"; ...