Skip to content

561. Array Partition Might be improved #847

Open
@AlexndrGetcel

Description

@AlexndrGetcel

🚀 Feature Proposal

Hello,
I have recently resolved the task number 561.
According to my understanding, the task do not concisely describes a problem.
For example, if we were going to find all possible pairs of elements, we should have had cartesian product of them.

Motivation

Description is not clearly describe a final achievable solution.

Contribution

Please consider the code below

public class task561 {
    public static void main(String[] args) {
        int [] nums = {1,4,3,2};


        int lng = nums.length - 1;
        int i = 0, j, l, k = lng;
        int count = Integer.MIN_VALUE, number = 0;

        while (i < lng){
            j = i + 1;
            while (j <= lng){
                while (k >= 0){
                    l = k - 1;
                    while (l >= 0){
                        number = Math.min(nums[i],nums[j]) + Math.min(nums[k], nums[l]);
                        l--;
                    }
                    k--;
                }
                k = lng;
                System.out.println(number);
                j++;
            }
            i++;
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions