So I am resolving this LC puzzle https://leetcode.com/problems/binary-search/description/ I think my code is almost there, it still comes with a couple of failed test cases like this (see the attached screenshot). Could anyone kindly point me in the right direction?
public static class Extensions{ public static int indexFinder<T>(this T[] nums, T target){ return Array.FindIndex(nums, val => val.Equals(target)); }}public class Solution { public int Search(int[] nums, int target) { if(nums.indexFinder(target) == -1){ return -1; } else { int index = nums.indexFinder(target); if(nums.indexFinder(target) != 1){ return index; } } return -1; }}
public static class Extensions{ public static int indexFinder<T>(this T[] nums, T target){ return Array.FindIndex(nums, val => val.Equals(target)); }}public class Solution { public int Search(int[] nums, int target) { if(nums.indexFinder(target) == -1){ return -1; } else { int index = nums.indexFinder(target); if(nums.indexFinder(target) != 1){ return index; } } return -1; }}