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

created max-twin-sum-in-list #1837 #1900

Merged
merged 3 commits into from
Nov 9, 2024
Merged

Conversation

SKG24
Copy link
Contributor

@SKG24 SKG24 commented Nov 6, 2024

In a linked list with an even number of nodes (size n), certain nodes are designated as "twins." Specifically, the i-th node (starting from index 0) is paired with the (n−1−i)-th node as its twin, for all i such that 0≤i≤(n/2)-1. In other words, the first node is paired with the last node, the second node with the second-last node, and so on, up to the midpoint of the list.

📥 Pull Request

Description

In a linked list with an even number of nodes, each node at index i is paired with the node at index n−1−i as its twin. The goal is to find the maximum "twin sum," which is the sum of the values of each pair. For example, in a list of 4 nodes, node 0 pairs with node 3, and node 1 pairs with node 2. The task is to find the maximum sum from all such pairs.

Fixes #1837

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
Screen.Recording.2024-11-06.at.10.30.13.PM.mov

Screenshot 2024-11-06 at 10 30 58 PM

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

In a linked list with an even number of nodes (size n), certain nodes are designated as "twins." Specifically, the i-th node (starting from index 0) is paired with the (n−1−i)-th node as its twin, for all i such that 0≤i≤(n/2)-1. In other words, the first node is paired with the last node, the second node with the second-last node, and so on, up to the midpoint of the list.
@SKG24 SKG24 requested a review from ajay-dhangar as a code owner November 6, 2024 17:01
Copy link

github-actions bot commented Nov 6, 2024

Thank you for submitting your pull request! 🙌 We'll review it as soon as possible.). If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊

We are given the head of a linked list, and an integer k.

Return the head of the linked list after swapping the values of the kth node from the beginning and the kth node from the end (the list is 1-indexed).
Copy link

github-actions bot commented Nov 6, 2024

⚡️ Lighthouse Report for the Deploy Preview of this PR 🚀

🔗 Site: Algo | Live Site

URL 🌐 Performance Accessibility Best Practices SEO 📊
/algo/ 🟡 53 🟢 96 🟡 71 🟡 86 📄
/algo/docs 🔴 46 🟢 96 🟡 75 🟢 100 📄
/algo/blog 🟡 67 🟢 92 🟢 96 🟡 86 📄

Given the head of a linked list with `n` nodes, for each node, find the value of the next node that is strictly greater. If no such node exists, return 0 for that position.

Return an integer array `answer` where `answer[i]` is the value of the next greater node of the `i`th node (1-indexed).
@SKG24
Copy link
Contributor Author

SKG24 commented Nov 8, 2024

this pull request has three issues i have worked on #1837 , #1838 , #1919

@SKG24
Copy link
Contributor Author

SKG24 commented Nov 8, 2024

please review my pr so that i can have clarity
thanks

@ajay-dhangar ajay-dhangar added gssoc-ext Contributions made as part of GirlScript Summer of Code Extended Edition. level2 GirlScript Summer of Code | Contributor's Levels labels Nov 9, 2024
Copy link
Owner

@ajay-dhangar ajay-dhangar left a comment

Choose a reason for hiding this comment

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

Done

@ajay-dhangar ajay-dhangar merged commit e34edc2 into ajay-dhangar:main Nov 9, 2024
5 of 6 checks passed
Copy link

github-actions bot commented Nov 9, 2024

🎉🎉 Thank you for your contribution! Your PR #1900 has been merged! 🎉🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gssoc-ext Contributions made as part of GirlScript Summer of Code Extended Edition. level2 GirlScript Summer of Code | Contributor's Levels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Idea]: Max Twin Sum of a Linked List
2 participants