Junior JavaScript Interview - Part 2: Algorithm + Debrief

Поделиться
HTML-код
  • Опубликовано: 12 ноя 2024

Комментарии • 11

  • @rdnexta
    @rdnexta 8 месяцев назад +1

    what is the name of this extention, when he typing, we saw somthing in front of that line. plz let me know.

  • @casull6447
    @casull6447 Год назад +1

    Thanks for your effort Justin

  • @harpo187bling
    @harpo187bling Год назад +1

    Thanks for these videos.

  • @RainOnline
    @RainOnline Год назад +1

    Would this be a good solve?
    function findUnique(arr) {
    let allArrs = [];
    for (let i = 0; i < arr.length; i++) {
    allArrs = allArrs.concat(arr[i]);
    }
    console.log([...new Set(allArrs)]);
    }
    findUnique(words);

  • @casull6447
    @casull6447 Год назад +1

    by the way here is my "amazing" solution for this question :)
    const uniqueArr = arr.map((subArr) => [...new Set([...subArr])]).flat(Infinity);
    const output = [];
    for (let i = 0; i < uniqueArr.length; i++) {
    if (
    ![...uniqueArr.slice(0, i), ...uniqueArr.slice(i + 1)].includes(
    uniqueArr[i]
    )
    ) {
    output.push(uniqueArr[i]);
    }
    }
    console.log(output);

  • @moezzzz9341
    @moezzzz9341 11 месяцев назад +1

    This should work in python
    def uniqueWords(wordsList):
    hashMap = {}
    counter = 0
    for words in wordsList:
    for idx in range(len(words)):
    currentWord = words[idx]
    if currentWord not in hashMap:
    hashMap[currentWord] = counter
    else:
    if hashMap[currentWord] != counter:
    del hashMap[currentWord]
    counter += 1
    return list(hashMap.keys())
    print(uniqueWords([["hello", "goodbye", "morning", "hello"], ["goodbye", "night"]]))
    Should return ['hello', 'morning', 'night']

  • @prakashsubba1373
    @prakashsubba1373 Год назад +1

    function uniqueWords(arr) {
    const obj = new Map();
    const result = [];
    for (let i = 0; i < arr.length; i++) {
    const removeDuplicate = [...new Set(arr[i])];
    removeDuplicate.forEach((word) => {
    if (obj.has(word)) {
    obj.set(word, obj.get(word) + 1);
    } else {
    obj.set(word, 1);
    }
    });
    }
    for (let [word, count] of obj) {
    if (count === 1) {
    result.push(word);
    }
    }
    return result;
    }

  • @dzdzdzdzjbjbjbjbbjbbjb
    @dzdzdzdzjbjbjbjbbjbbjb Год назад +1

    const uniqueWords = arrayOfArrays.reduce(folder, [])
    const folder = (met, next) =>
    ( met.filter(e => !next.includes(e))
    ).concat([... new Set(next)].filter(e => !met.includes(e)))

  • @c-cg
    @c-cg Год назад +1

    const returnSingleAppearance = (arr) => {
    const unique = [];
    arr.forEach((strArray) =>
    strArray.forEach((string) => {
    const index = unique.indexOf(string);
    index >= 0 ? unique.splice(index, 1) : unique.push(string);
    })
    );
    return unique;
    };