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

1822 - Sign of the Product of an Array #2688

Merged
merged 2 commits into from
Jul 11, 2023
Merged

1822 - Sign of the Product of an Array #2688

merged 2 commits into from
Jul 11, 2023

Conversation

AHTHneeuhl
Copy link
Contributor

Important

Please make sure the file name is lowercase and a duplicate file does not already exist before merging.


for (const num of nums) {
if (num == 0) return 0;
else if (num < 0) sign = -1 * sign;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Avoid else

if (canSkip) continue;
if (canBreak) break;
if (canExit) return;

// else ...

if (isPositive) sign *= -1;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the code!

@AHTHneeuhl AHTHneeuhl requested a review from aakhtar3 July 11, 2023 18:38
@aakhtar3 aakhtar3 merged commit c7ce625 into neetcode-gh:main Jul 11, 2023
@AHTHneeuhl AHTHneeuhl deleted the 1822 branch July 11, 2023 20:01
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

Successfully merging this pull request may close these issues.

2 participants