java - Max absolute sum in a array -


I have recently come to this question but have not got any ideas about solving it. Can you do some help with pseudo-code?

Looking at an array with four, integer A, B, C, D, drag them in a sequence if the integers are complete then 24 shuffles are my work best adjusted as if

  F (s [0] -s [1]) + abs (s [1] -s [2]) + eb (s [2] -s [ 3])   

is the maximum

For example, consider this example

  A = 5, b = 3, c = -1, d = 5s [0] = 5, s [1] = - 1, s [2] = 5, s [3] = 3   

I will be given the highest amount which will be

  f [s] = 14   

The complexity of time and place o (1).

Since the size of your array is surrounded, any algorithm you Use closing time and space complexity will be o (1). Therefore, the simple algorithm of "Try all permutations and find the best" will solve the problem in the appropriate time frame. I do not have to say that this is the ideal algorithm from any section of the imagery, but if you only need all the things that work in time / space (1), you got it Is your answer

Hope it helps!

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -