Skip to content

Commit 51e1dda

Browse files
alvinphilipsgithub-actionsPanquesito7
authored
fix: Union of two arrays (#1794)
* Create reverse_binary_tree.cpp * Added documentation Added Documentation for the level_order_traversal() function, and implemented a print() function to display the tree to STDOUT * Added documentation * Renamed tests to test * Fixed issue with incorrect using statement * updating DIRECTORY.md * clang-format and clang-tidy fixes for fb86292 * Added Test cases * Update operations_on_datastructures/reverse_binary_tree.cpp Co-authored-by: David Leal <[email protected]> * Update operations_on_datastructures/reverse_binary_tree.cpp Co-authored-by: David Leal <[email protected]> * Update operations_on_datastructures/reverse_binary_tree.cpp Co-authored-by: David Leal <[email protected]> * Update operations_on_datastructures/reverse_binary_tree.cpp Co-authored-by: David Leal <[email protected]> * Update operations_on_datastructures/reverse_binary_tree.cpp Co-authored-by: David Leal <[email protected]> * Changed int to int64_t * Updated documentation wording * Fixed wrong integer type Changed int64_t to int32_t * clang-format and clang-tidy fixes for 2af706b Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: David Leal <[email protected]>
1 parent 6c67471 commit 51e1dda

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

math/check_prime.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
* @brief
88
* Reduced all possibilities of a number which cannot be prime.
99
* Eg: No even number, except 2 can be a prime number, hence we will increment
10-
* our loop with i+6 jumping and check for i or i+2 to be a factor of the number;
11-
* if it's a factor then we will return false otherwise true after the loop terminates at the terminating condition which is (i*i<=num)
10+
* our loop with i+6 jumping and check for i or i+2 to be a factor of the
11+
* number; if it's a factor then we will return false otherwise true after the
12+
* loop terminates at the terminating condition which is (i*i<=num)
1213
*/
1314

14-
#include <cassert> /// for assert
15-
#include <iostream> /// for IO operations
15+
#include <cassert> /// for assert
16+
#include <iostream> /// for IO operations
1617

1718
/**
1819
* Function to check if the given number is prime or not.
@@ -24,14 +25,13 @@ bool is_prime(T num) {
2425
bool result = true;
2526
if (num <= 1) {
2627
return false;
27-
} else if (num == 2 || num==3) {
28+
} else if (num == 2 || num == 3) {
2829
return true;
29-
} else if ((num%2) == 0 || num%3 == 0) {
30+
} else if ((num % 2) == 0 || num % 3 == 0) {
3031
return false;
31-
}
32-
else {
32+
} else {
3333
for (T i = 5; (i * i) <= (num); i = (i + 6)) {
34-
if ((num % i) == 0 || (num%(i+2)==0 )) {
34+
if ((num % i) == 0 || (num % (i + 2) == 0)) {
3535
result = false;
3636
break;
3737
}

operations_on_datastructures/union_of_two_arrays.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace operations_on_datastructures {
2828
* @returns void
2929
*/
3030
void print(const std::vector<int32_t> &array) {
31-
for (int64_t i : array) {
31+
for (int32_t i : array) {
3232
std::cout << i << " "; /// Print each value in the array
3333
}
3434
std::cout << "\n"; /// Print newline

0 commit comments

Comments
 (0)