forked from TheAlgorithms/C
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request TheAlgorithms#337 from CertifiedBlyndGuy/master
leetcode: Address readability of a few cases, and fix 283
- Loading branch information
Showing
10 changed files
with
48 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
void moveZeroes(int* nums, int numsSize){ | ||
int i, start = 0; | ||
void moveZeroes(int* nums, int numsSize) { | ||
int i = 0, start = 0; | ||
|
||
for (i = 0; i < numsSize; i++) { | ||
if(nums[i]) | ||
if (nums[i]) | ||
nums[start++] = nums[i]; | ||
} | ||
for(;start < numsSize; start++) { | ||
|
||
for (start; start < numsSize; start++) { | ||
nums[start] = 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
int rangeSumBST(struct TreeNode* root, int L, int R){ | ||
if (root == NULL) | ||
if (root == NULL) { | ||
return 0; | ||
else if (root->val >= L && root->val <= R) | ||
} else if (root->val >= L && root->val <= R) { | ||
return root->val + rangeSumBST(root->left, L, R) + rangeSumBST(root->right, L, R); | ||
else | ||
} else { | ||
return rangeSumBST(root->left, L, R) + rangeSumBST(root->right, L, R); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters