function filterPrefix(prefix, words) {
        var results = [];
        for (var i = 0; i < words.length; i++) {
            if (words[i].indexOf(prefix) === 0) {
                results.push(words[i]);
            }
        }
        return results;
    }
// NOTE: Naive implementation O(n), can be O(log n) with binary search

Naive implementation O(n), can be O(log n) with binary search
Naive implementation O ( n ) can be O ( log n ) with binary search
function filterPrefix(prefix, words) {
        var results = [];
        for (var i = 0; i < words.length; i++) {
            if (words[i].indexOf(prefix) === 0) {
                results.push(words[i]);
            }
        }
        return results;
    }
function filterPrefix ( prefix , words ) { var results = [ ] ; for ( var i = 0 ; i < words . length ; i ++ ) { if ( words [ i ] . indexOf ( prefix ) === 0 ) { results . push ( words [ i ] ) ; } } return results ; }
NOTE: Naive implementation O(n), can be O(log n) with binary search
NOTE : Naive implementation O ( n ) can be O ( log n ) with binary search