Simple Java Solution O(logn)

public class Solution {
public ArrayList searchRange(final List a, int b) {
ArrayList ku=new ArrayList();
int count=0;
for(int i=0;i<a.size();i++){ if(a.get(i)==b){
ku.add(i);
count=1;
break;
}
}
if(count==1){
for(int i=a.size()-1;i>=0;i–){

        if(a.get(i)==b){
            ku.add(i);
            count=2;
            break;
        }
        
        
    }       
    }
    if(count==2)
    return ku;
    else{
        ku.add(-1);
        ku.add(-1);
        return ku;
    }
    }

}

Click here to start solving coding interview questions