The Card Game One day, Fred and his N friends were playing a card game in which each…
- User
The Card Game One day, Fred and his N friends were playing a card game in which each player throws a card with a number written on it. The cards are such that a number X is written on front of the card, and the negative of that number is written on the back side of the card. This game has the following rules: - Each of the N players is asked to throw a card. After a,' the N cards are thrown, Fred has to flip one or more cards in consecutive order, only once. Your task is to help Fred flip the cards in such a way that the sum of the numbers, on front face of the cards, is the maximum. Input Specification: inputl: An integer N denoting the number of cards (I <:: N 500) input2: An integer array containing N integers, where the ith integer denotes the value on the front of the card (-1000 1000) Output Specification: Return the maximum sum of the numbers, on the front of the card in java
- Assistant
- User
Black and White Walls There are N black and white colored walls (I N < 89). You are given a string array named colors , where each element of the array is either "White" or "Black" , representing the initial color of the walls. You can choose a black wall and a white wall and swap their colors at some cost. You may perform this swapping operation any number of times. The cost of swapping the color of the i-th (1 i N) white-colored wall with the j-th (1 j N) black-colored wall is calculated as li — jl. Your task is to find and return the minimum cost required to change all initially black-colored walls to white-colored walls using the method mentioned above. Note: • Initially, the total number of black walls is not greater than half of the total number of walls. • Consider 1 -based indexing.
code in java
- Assistant
- User
please write recursion of this
- Assistant