Class: Algorithmable::Cups::TwoSum::Logarithmic

Inherits:
Object
  • Object
show all
Defined in:
lib/algorithmable/cups/two_sum.rb

Overview

public class Solution {

public int[] twoSum(int[] numbers, int target) {

HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); int[] result = new int;

for (int i = 0; i < numbers.length; i++) { if (map.containsKey(numbers)) { int index = map.get(numbers); result = index+1 ; result = i+1; break; } else { map.put(target - numbers, i); } }

return result;

}

}

Instance Method Summary collapse

Instance Method Details

#solve(collection, target) ⇒ Object


50
51
# File 'lib/algorithmable/cups/two_sum.rb', line 50

def solve(collection, target)
end