Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
shovan04 wants to merge 1 commit into quicksnip-dev:main from shovan04:main
Closed

Add Some Array Manipulation in CPP #23

shovan04 wants to merge 1 commit into quicksnip-dev:main from shovan04:main

Conversation

Copy link

@shovan04 shovan04 commented Dec 30, 2024

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
edited
Loading

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.

Copy link
Collaborator

Hey, there! Thanks for the contribution. 🙌

Copy link
Collaborator

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

Copy link
Author

Hey, there! Thanks for the contribution. 🙌

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

Copy link
Collaborator

@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

@Mathys-Gasnier Mathys-Gasnier Dec 30, 2024

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
Copy link
Collaborator

saminjay commented Dec 30, 2024
edited
Loading

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.

technoph1le reacted with thumbs up emoji

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

@saminjay saminjay Dec 30, 2024
edited
Loading

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?

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
Copy link
Collaborator

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

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

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
Reviewers

@saminjay saminjay saminjay left review comments

@Mathys-Gasnier Mathys-Gasnier Awaiting requested review from Mathys-Gasnier Mathys-Gasnier is a code owner

Assignees
No one assigned
Labels
Snippets update needed Code needs to be updated.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /