Two Sum in Matlab

  • 0

    Given an input array of positive numbers & a positive scalar find the first target hit/match

    % yelp interview matlab impl.
    function result = twosum(A, target)
       indices = A((target-A)>0 & ismember((target-A), A));
       result =  find (A , indices(1));

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.