LeetCode #1 [Two Sum] In C Language Solutions

preview_player
Показать описание
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

You can return the answer in any order.

Solution :

In this solution, the twoSum function takes in three arguments: an array of integers nums, the size of the array numsSize, and an integer target. It returns an array of length 2 that contains the indices of the two numbers that add up to the target.

To find the indices of the two numbers, the function iterates over the array and checks if the target can be formed by adding two elements from
Рекомендации по теме