• + 0 comments

    I had difficulty understanding what was to be done (I don't speak English natively).

    So I decided to divide the code like this:

    const getMaxLessThanK = (n,k) => {
        let maxBitwiseValue = 0
        const bitwiseValues = []
    
        for(let a = 1; a < n; a++){
            for(let b = a + 1; b <= n; b++){
                bitwiseValues.push(a & b)
            }
        }
        
        bitwiseValues.forEach(bitwiseValue => {
            if(bitwiseValue < k && bitwiseValue > maxBitwiseValue){
                maxBitwiseValue = bitwiseValue
            }
        })
    
        return maxBitwiseValue   
    }