Java 5 lines solution


  • 0
    C
    public class Solution {
    public int search(int[] nums, int target) {
        for(int i=0;i<nums.length;i++)
            if(nums[i] == target)return i;
        return -1;}}

Log in to reply
 

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