leetcode/include/s0001_two_sum.hpp

30 lines
683 B
C++
Raw Permalink Normal View History

2022-03-12 03:04:49 +00:00
#ifndef S0001_TWO_SUM_HPP
#define S0001_TWO_SUM_HPP
2022-03-08 07:54:17 +00:00
#include <iostream>
#include <unordered_map>
#include <vector>
2022-11-30 10:20:36 +00:00
using namespace std;
class S0001 {
2022-03-08 07:54:17 +00:00
public:
/**
* @brief Two Sum
*
* 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.
*
* @param nums the array of integers to be summed
* @param target the target integer
*/
std::vector<int> twoSum(std::vector<int>& nums, int target);
};
#endif