Skip to content
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

Optimized the code of 4SumJava problem #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 4sumJava
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class Solution {

Arrays.sort(num);

for (int i = 0; i < n; i++) {
for (int i = 0; i < n-3; i++) {

int target_3 = target - num[i];

for (int j = i + 1; j < n; j++) {
for (int j = i + 1; j < n-2; j++) {

int target_2 = target_3 - num[j];

Expand Down