title: Finding two associated indexes where the sum of two elements equals a target value
body: <p><strong>Background:</strong></p>
  
  <p>Given an array of integers, return indices of the two numbers such that they add up to a specific target.</p>
  
  <p>You may assume that each input would have exactly one solution, and you may not use the same element twice.</p>
  
  <p><strong>Example:</strong></p>
  
  <p>Given nums = [2, 7, 11, 15], target = 9,</p>
  
  <p>Because nums[0] + nums[1] = 2 + 7 = 9,</p>
  
  <p>return [0, 1].</p>
  
  <p><strong>Question:</strong></p>
  
  <p>I have a list of numbers 1,2,3,4,5. My target value is 8, so I should return indices  2 and 4. My first thought is to write a a double for loop that checks to see if adding two elements from the list will get my target value. Although, when checking to see if there is such a solution, my code returns that there is none. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  
  int main() {
  
      vector&lt;int&gt; list;
      list.push_back(1);
      list.push_back(2);
      list.push_back(3);
      list.push_back(4);
      list.push_back(5);
  
      int target = 8;
  
  
      string result;
      for(int i = 0; i &lt; list.size(); i++) {
          for(int j = i+1; j &lt; list.size(); j++) {
              if(list[i] + list[j] == target) {
                  result = "There is a solution";
              }
              else {
                  result = "There is no solution";
              }
          }
  
      }
  
      cout &lt;&lt; result &lt;&lt; endl;
  
  
      return 0;
  }
  </code></pre>
  
  <p>Perhaps my approach/thinking is plain wrong. Could anyone provide any hints or suggestions to solving this problem?</p>