Skip to content

Add Some Array Manipulation in CPP #23

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

Closed
wants to merge 1 commit into from

Conversation

shovan04
Copy link

Find Minimum and Maximum Values in an Array: Efficiently identifies the smallest and largest values in a given array using a single traversal.
Find Second Largest Element in an Array: Determines the second-largest element with minimal overhead using only a single loop.
Sort Array in Descending Order: Implements the Bubble Sort algorithm to sort an array in descending order.
Find Common Elements in Two Arrays: Identifies common elements between two arrays without requiring additional data structures, using marking for tracking matches.

Copy link

netlify bot commented Dec 30, 2024

Deploy Preview for quicksnip ready!

Name Link
🔨 Latest commit 73a70ba
🔍 Latest deploy log https://app.netlify.com/sites/quicksnip/deploys/677263910a013b0008a2a92e
😎 Deploy Preview https://deploy-preview-23--quicksnip.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@technoph1le
Copy link
Owner

Hey, there! Thanks for the contribution. 🙌

@technoph1le
Copy link
Owner

@saminjay and @Mathys-Gasnier, what do you think about these snippets?

@shovan04
Copy link
Author

Hey, there! Thanks for the contribution. 🙌

@dostonnabotov, But the changes aren't showing on the site. What's the issue?

@technoph1le
Copy link
Owner

@dostonnabotov, But the changes aren't showing on the site. What's the issue?

Changes won't be visible until merged into main branch. You can view changes from here:

Preview panel

Copy link
Collaborator

@Mathys-Gasnier Mathys-Gasnier left a comment

Choose a reason for hiding this comment

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

Those are in the cpp examples but dont really use that much cpp features over c ones.
Please changes things like function taking c array to cpp vectors and such.

"#include <climits>",
"",
"",
"void findCommonElements(const int arr1[], int size1, int arr2[], int size2, int& commonCount) {",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a fan of this function too,
It doesn't return the common elements but the number of common elements.
It also modifies one the array which can be non desired behavior...

@technoph1le technoph1le added the discuss Needs to be discussed by community label Dec 30, 2024
@saminjay
Copy link
Collaborator

saminjay commented Dec 30, 2024

Most of these functions are just common DSA solutions. They aren't exactly "handy" because you rarely use them. I don't know if this is wanted, @dostonnabotov can clear that up.
But even then I don't see the use of Bubble Sort descending function. STL already provides a std::sort function, that can sort any iterable and you can also pass a comparision function.

"author": "shovan04"
},
{
"title": "Find Second Largest Element in an Array",
Copy link
Collaborator

@saminjay saminjay Dec 30, 2024

Choose a reason for hiding this comment

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

Instead of this function, can you make a generalised function that returns Largest k elements?

@saminjay
Copy link
Collaborator

Also I think for a snippet function it is always better to return the result rather than modifying the passed variables.

@technoph1le technoph1le added update needed Code needs to be updated. and removed discuss Needs to be discussed by community labels Dec 30, 2024
@Mathys-Gasnier
Copy link
Collaborator

Before requesting another review please review what was said to you, and changes things that were asked.

@Mathys-Gasnier
Copy link
Collaborator

Hey, we recently updated how snippets are stored, please update your PR to match the changes, you will be able to see how to add snippets in CONTRIBUTING.md.
For ref: #87

@Mathys-Gasnier
Copy link
Collaborator

Hey, changes were requested on your PR, but we got no news for more than a week, Closing this as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Snippets update needed Code needs to be updated.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants