Skip to content

561. Array Partition Might be improved #847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AlexndrGetcel opened this issue Oct 12, 2022 · 0 comments
Open

561. Array Partition Might be improved #847

AlexndrGetcel opened this issue Oct 12, 2022 · 0 comments

Comments

@AlexndrGetcel
Copy link

🚀 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++;
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant