[PR #1504] [CLOSED] feat: add LeetCode problem 167 #2110

Open
opened 2026-01-29 15:28:51 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/TheAlgorithms/C/pull/1504
Author: @Vaibhav-Patidar
Created: 10/20/2025
Status: Closed

Base: masterHead: solution/two-sum-ii


📝 Commits (1)

  • a77ee41 Add solution for Two Sum II

📊 Changes

2 files changed (+28 additions, -0 deletions)

View changed files

leetcode/src/.DS_Store (+0 -0)
leetcode/src/167.c (+28 -0)

📄 Description

Description of Change

Implemented the Two Sum II solution using the two-pointer approach. The function takes a sorted array and returns the 1-based indices of the two numbers whose sum equals the given target. It uses a single pass with O(n) time complexity and O(1) extra space. The result array is dynamically allocated, with memory management handled by the caller.

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes: Added the solution for Leetcode problem no.167 Two-Sum-II


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/TheAlgorithms/C/pull/1504 **Author:** [@Vaibhav-Patidar](https://github.com/Vaibhav-Patidar) **Created:** 10/20/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `solution/two-sum-ii` --- ### 📝 Commits (1) - [`a77ee41`](https://github.com/TheAlgorithms/C/commit/a77ee413fb8e259c14703060a02f21ae8dbebf69) Add solution for Two Sum II ### 📊 Changes **2 files changed** (+28 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `leetcode/src/.DS_Store` (+0 -0) ➕ `leetcode/src/167.c` (+28 -0) </details> ### 📄 Description #### Description of Change Implemented the Two Sum II solution using the two-pointer approach. The function takes a sorted array and returns the 1-based indices of the two numbers whose sum equals the given target. It uses a single pass with O(n) time complexity and O(1) extra space. The result array is dynamically allocated, with memory management handled by the caller. #### Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [ ] Added description of change - [ ] Added file name matches [File name guidelines](https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md#File-Name-guidelines) - [ ] Added tests and example, test must pass - [ ] Relevant documentation/comments is changed or added - [ ] PR title follows semantic [commit guidelines](https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md#Commit-Guidelines) - [ ] Search previous suggestions before making a new one, as yours may be a duplicate. - [ ] I acknowledge that all my contributions will be made under the project's license. Notes: Added the solution for Leetcode problem no.167 Two-Sum-II --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 15:28:51 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/C#2110