Two Sum in Matlab


  • 0
    M

    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));
    end
    

Log in to reply
 

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