title: sumOfTwo Time Limit Exceeded CodeFights Interview Practice
body: <p>I am attempting the sumOFTwo challenge on CodeFights.com but I unfortuantly cannot complete it to view the solution. All my tests suceedd until the 15th hidden test and it says it exceeds the time limit. </p>
  
  <p>The challenge is - You have two integer arrays, a and b, and an integer target value v. Determine whether there is a pair of numbers, where one number is taken from a and the other from b, that can be added together to get a sum of v. Return true if such a pair exists, otherwise return false.</p>
  
  <p>My code is - </p>
  
  <pre><code>def sumOfTwo(a,b,v):
      a.sort()
      b.sort()
  
      if(0 in a and v in b):
          return True
      elif(v in a and 0 in b):
          return True
      else:
          for i in a:
              for j in b:
                  if(i + j == v):
                      return True
      return False
  </code></pre>
  
  <p>I know it could be shrunken down to about 6 lines of code, but I kept adding in lines that could help the code possibly finish quicker. Are there any other optimizations I am missing. </p>