Top 10 Javascript Algorithms to Prepare for Coding Interviews

Поделиться
HTML-код
  • Опубликовано: 11 май 2024
  • Build a solid foundation and prepare you for Leetcode-style coding challenges. Learn the top 10 must-know Javascript algorithms interview questions to help you ace your coding interviews. This course will help you build a strong foundation in Javascript algorithms and tackle Leetcode problems with confidence.
    💻 Code: github.com/codingmoney/javasc...
    ✏️ Course developed by @CodingMoney
    ⌨️ (0:00:00) Introduction
    ⌨️ (0:01:00) Reverse String & Integers
    ⌨️ (0:11:29) Palindrome
    ⌨️ (0:15:58) Max Char
    ⌨️ (0:33:43) Array Chunking
    ⌨️ (0:41:56) Title Case
    ⌨️ (0:49:31) Anagrams
    ⌨️ (1:07:54) Count Vowels
    ⌨️ (1:15:21) Fizz Buzz
    ⌨️ (1:20:02) Steps String Pattern
    ⌨️ (1:30:52) Pyramid String Pattern
    ⌨️ (1:39:24) Bonus - Spiral Matrix
    🎉 Thanks to our Champion and Sponsor supporters:
    👾 davthecoder
    👾 jedi-or-sith
    👾 南宮千影
    👾 Agustín Kussrow
    👾 Nattira Maneerat
    👾 Heather Wcislo
    👾 Serhiy Kalinets
    👾 Justin Hual
    👾 Otis Morgan
    👾 Oscar Rahnama
    --
    Learn to code for free and get a developer job: www.freecodecamp.org
    Read hundreds of articles on programming: freecodecamp.org/news

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

  • @CodingMoney
    @CodingMoney 2 месяца назад +21

    1:00 Reverse String & Integers
    11:29 Palindrome
    15:58 Max Char
    33:43 Array Chunking
    41:56 Title Case
    49:31 Anagrams
    1:07:54 Count Vowels
    1:15:21 Fizz Buzz
    1:20:02 Steps String Pattern
    1:30:52 Pyramid String Pattern
    1:39:24 Bonus - Spiral Matrix

  • @sayedrezaomid1305
    @sayedrezaomid1305 2 месяца назад +10

    I am very happy that i saw my Afghan and ex colleaque trainings at this channel.

  • @augustoeduardo209
    @augustoeduardo209 2 месяца назад +17

    Beatiful countryside landscape.

  • @daisy_haniii
    @daisy_haniii Месяц назад +2

    Palindrome using two pointers technique:
    function isPalindrome(str) {
    let min = 0
    let max = str.length - 1
    do {
    if(str[min] == str[max]) {
    min++
    max--
    } else {
    return false
    }
    }while(min < max)

    return true
    }

  • @MyCodingDiarie
    @MyCodingDiarie 2 месяца назад +3

    You're changing lives with your content. Keep inspiring!

  • @orangeprogrammer
    @orangeprogrammer 2 месяца назад +3

    Awesome video! Thank you for making it 😀

  • @WhitneyChakara
    @WhitneyChakara Месяц назад +1

    This is excellent and able to be completed as it's short and straight to the point.

  • @khanhphamthanh5012
    @khanhphamthanh5012 Месяц назад +3

    amazing spiral Matrix. It really so hard for me to find out the way. Thank you for your code

  • @arzoohashimi519
    @arzoohashimi519 2 месяца назад +3

    Very informative and helpful.

  • @user-dy8si5bf8t
    @user-dy8si5bf8t 2 месяца назад +2

    So engaging and interesting thank you sir for this lecture ❤

  • @marioerichsen1977
    @marioerichsen1977 Месяц назад +1

    function palindrome(str) {
    //with two pointer technique
    var stringArr = str.split('')
    const reverseArray = (arr) => {
    let i = 0;
    let j = arr.length-1;
    while (i < j) {
    let tmp = arr[i];
    arr[i++] = arr[j];
    arr[j--] = tmp;
    };
    return arr
    };
    const reversed = reverseArray(stringArr)
    return str === stringArr.join('')
    }

  • @sergeynazarov2473
    @sergeynazarov2473 Месяц назад +1

    Perfect, trainees will be ready!

  • @atultrp1
    @atultrp1 2 месяца назад +3

    // every method
    function palindrome(str) {
    return str.split('').every((ele, i) => {
    return ele == str[str.length - i - 1]
    })
    }
    // two pointer technique
    function palindrome2(str) {
    let start = 0
    let last = str.length - 1
    while (start < last) {
    if (str[start] != str[last]) {
    return false
    }
    else {
    start++
    last--
    }
    }
    return true
    }

  • @LokeshKumar-tk7ri
    @LokeshKumar-tk7ri Месяц назад

    Thank you Free code Camp for providing DSA in Javascript and also need more content on JS DSA

  • @shulamohammad2275
    @shulamohammad2275 2 месяца назад

    loved the tutorial by Mukhtar!

  • @ajiteshmishra0005
    @ajiteshmishra0005 4 дня назад

    We want more videos on these String and Array manipulation methods and programming questions

  • @murshidalam1982
    @murshidalam1982 2 месяца назад +1

    Very helpful.

  • @Adolfofilipe7369
    @Adolfofilipe7369 2 месяца назад +1

    Thanks for your help 🎉🎉🎉🎉🎉🎉

  • @lazarokabira2945
    @lazarokabira2945 2 месяца назад +3

    Love this

  • @user-lp1jw1fq7d
    @user-lp1jw1fq7d 2 месяца назад +2

    Love this video ❤

  • @ajiteshmishra0005
    @ajiteshmishra0005 4 дня назад

    We are learning well from these type of Videos
    But please zoom in something more so that we can see the screen properly.

  • @savchenkoilliya9131
    @savchenkoilliya9131 2 месяца назад +1

    In my opinion I can give better and more javascript-style solutions for at least couple tasks. Maybe it's a little bit harder to read, but it works better when we are talking about js:
    var chunk = (array, size) =>
    (array.length (str.split(" ")
    .map((word)=>
    (word.charAt(0).toUpperCase() + word.slice(1)).join(" ")))
    P.S.
    Good practice show O(n) complexity for each solution, because it's a think that can be asked on any interview.

  • @user-cu7tw3vb2k
    @user-cu7tw3vb2k 2 месяца назад

    Q1:
    function reverseIt(str){
    let newArr = '';
    for(let i = 0; i< str.length ; i ++)
    {
    newArr += str[str.length -i-1];
    }
    return newArr;
    }
    console.log(reverseIt('hello'))

  • @DavidMorenoH
    @DavidMorenoH 2 месяца назад +7

    OMG please do this but with Java or Python

    • @adlen01
      @adlen01 Месяц назад

      Ther is ful apk in webstores

  • @narekmeliksetyan9262
    @narekmeliksetyan9262 2 месяца назад +1

    it was very useful. but I will suggest the following solution for problem 9.
    function foo(n){
    for(i=1;i

    • @vnm_8945
      @vnm_8945 Месяц назад

      You could just use Array(i) instead of Array.from({length:i}), nice solution!

  • @edwarddk9007
    @edwarddk9007 15 дней назад

    my solution for the Pyramid String Pattern exercise: function pyramid(n, level, body, space) {
    if(level

  • @dudekool12
    @dudekool12 2 месяца назад

    Need this in Python!

  • @MS-gi3hc
    @MS-gi3hc 2 месяца назад

    Thank you

  • @user-ko6zp7rt6b
    @user-ko6zp7rt6b Месяц назад

    function isPolindrom(str) {
    let check = str.split('').reverse().join('');
    return str === check ? true : false
    }

  • @ITRebels
    @ITRebels Месяц назад

    awesome

  • @mr_aha4713
    @mr_aha4713 2 месяца назад

    12:23
    function pal(str){
    console.log(str)
    if (str === str.split('').reverse().join('')){
    return true
    }else {
    return false
    }
    }
    console.log(pal(""))

  • @-.nisa.-
    @-.nisa.- 2 месяца назад

    1:39:20 This is such an overcomplication... One 'for' loop is more than enough here:
    for (let i = 1; i

    • @arzoohashimi519
      @arzoohashimi519 2 месяца назад

      Big o notation for repeat function is o(n) which is similar to a for loop. So ur solution is also the same.

  • @alikh5601
    @alikh5601 2 месяца назад +3

    Saved

  • @moshtabamorsali
    @moshtabamorsali 7 дней назад

    I did each of them in a different way but still working in the same performance😶‍🌫

  • @m0slah
    @m0slah 2 месяца назад +3

  • @ajmalshahanpm938
    @ajmalshahanpm938 Месяц назад

    function count(str){
    let counter=0;
    // for(let i=0;ifi===str[i])) {
    // counter++;
    // }
    // }
    for(single of str){
    if (['a','i','o','e','u'].some((fi)=>fi===single)) {
    counter++;
    }
    }
    return counter;
    }
    console.log(count("aj code"));

  • @SaeedITSpot
    @SaeedITSpot Месяц назад

    🎉🎉🎉

  • @vijayakabajo
    @vijayakabajo Месяц назад

    0:22 He owns a farm

  • @user-ko6zp7rt6b
    @user-ko6zp7rt6b 28 дней назад

    function checkVowels(str) {
    let arr = []
    const vowelsArray = ['a', 'e', 'i', 'o', 'u']
    let arrFrStr = str.toLowerCase().split('')
    for (let i of vowelsArray) {
    for (let y of arrFrStr) {
    if (i === y) {
    arr.push(i)
    }
    }
    }
    return arr.length
    }

  • @g0nt411
    @g0nt411 Месяц назад

    Honestly, any companies could ask questions like these?

  • @rishiraj2548
    @rishiraj2548 2 месяца назад +3

    👍🙂👍

  • @ajiteshmishra0005
    @ajiteshmishra0005 4 дня назад

    for(var i = 1; i {
    console.log(i);
    }, 1200);
    }
    Output is
    4
    4
    4
    &
    for(let i = 1; i {
    console.log(i);
    }, 1200);
    }
    Output is
    1
    2
    3
    Why??

    • @giftedfingers2580
      @giftedfingers2580 2 дня назад

      The for loop is using var which in turn the compiler recognizes the var but not its value. Second, the setTimeout has an arrow function and that creates a closure.

  • @subashstino899
    @subashstino899 2 месяца назад

    Is this MERN Stack developer needs to Study DSA ???… And I want to know Any best book for DSA( Data structure and algorithms )……????

    • @feerfeja
      @feerfeja 2 месяца назад

      this video course is the best for learning algorithms in Javascript :p

  • @phyapanchakpram
    @phyapanchakpram 29 дней назад

    //alternate newbie solution
    function capitilizeFirstLetter(str) {
    let arr = str.split(' ');
    let result = [];
    for(let s of arr) {
    result.push(s.charAt(0).toUpperCase() + s.substr(1))
    }
    return result.toString().replace(/,/g,' ');
    }

  • @phyapanchakpram
    @phyapanchakpram 29 дней назад

    //To return all char if max occurence has more than one time
    function maxOccurence(str) {
    let charMap = {};
    for(let char of str) {
    charMap[char] = (charMap[char] || 0) + 1;
    }
    let max = 0;
    let maxChar = [];
    for(let key in charMap) {
    if(charMap[key] > max){
    max = charMap[key];
    }
    }
    for(let char in charMap) {
    if(charMap[char] === max) {
    maxChar.push(char);
    }
    }
    return maxChar;
    }

  • @HazimTulumovic
    @HazimTulumovic 12 дней назад

    Max chars :
    function maxChar(str) {
    const usedChars = {};
    for (const char of str) {
    usedChars[char] = usedChars[char] ? usedChars[char] + 1 : 1;
    }
    return Object.keys(usedChars).sort((a, b) => usedChars[b] - usedChars[a])[0];
    }

  • @dogukankarabeyin3059
    @dogukankarabeyin3059 Месяц назад

    Guys these questions and answers are identical to Stephen Grider's Coding Interview Bootcamp udemy course. I get these are common questions but it just seemed too similar.

  • @OthmaneAHMARLAHYA
    @OthmaneAHMARLAHYA 2 месяца назад +2

    i'm sure no one understand this

  • @nicolasmanns7249
    @nicolasmanns7249 16 дней назад

    Palindrome with some kind of two pointers made with a for loop (also removes caps and spaces)
    function palindrome(str) {
    strToTest = str.toLowerCase().split(" ").join("");
    let isPalindrome = true;
    for (let i = 0; i

  • @DavidDroddy
    @DavidDroddy Месяц назад

    For String and Int reversal and Palindrome -- .every and two pointer techniques:
    // STRING.SPLIT INTO ARRAY
    //const reverseString = (theString) => theString.split('').reverse().join('');
    // SPREAD STRING(ARRAY-OF-CHARACTERS) INTO ARRAY
    // const reverseString = (theString) => [...theString].reverse().join('');
    // ARRAY.EVERY(element, index, array)
    const reverseString = (theString) => {
    let reversedString = '';
    const reversiosa = (character, i, charArray) => {
    // using index and array (all tests pass)
    // let lastElement = charArray[charArray.length - ++i];
    // return reversedString += lastElement;
    const j = charArray.length - (++i)
    return reversedString += charArray[j];
    // using element (all tests pass)
    // return reversedString = character + reversedString;
    };
    [...theString].every(reversiosa)
    return reversedString;
    }
    // "TWO POINTER" SOLUTION
    // const reverseString = (theString) => {
    // let i = 0;
    // let j = theString.length-1;
    // let stringArray = [...theString];
    // while(i parseInt(reverseString(theNumber.toString())) * Math.sign(theNumber);
    const isPalindrome = (theString) => reverseString(theString) === theString;
    // TESTS
    const stringToReverse = 'jar';
    const expectedReversedString = 'raj';
    const reversedString = reverseString(stringToReverse);
    let expectedAndReceived = `expected: ${expectedReversedString}; received: ${reversedString}`;
    if(reversedString === expectedReversedString) {
    console.log(`pass - reverseString('${stringToReverse}')
    ${expectedAndReceived}`);
    } else {
    console.error(`FAIL - reverseString('${stringToReverse}')
    ${expectedAndReceived}`);
    }
    let intToReverse = 53;
    let expectedReversedInt = 35;
    let reversedInt = reverseInt(intToReverse);
    expectedAndReceived = `expected: ${expectedReversedInt}; received: ${reversedInt};`;
    if(reversedInt === expectedReversedInt){
    console.log(`pass - reverse a POSITIVE integer
    reverseInt(${intToReverse})
    ${expectedAndReceived}`);
    } else {
    console.error(`FAIL - reverse a POSITIVE integer
    reverseInt(${intToReverse})
    ${expectedAndReceived}`);
    }
    intToReverse = -54;
    expectedReversedInt = -45;
    reversedInt = reverseInt(intToReverse);
    expectedAndReceived = `expected: ${expectedReversedInt}; received: ${reversedInt};`;
    if(reversedInt === expectedReversedInt){
    console.log(`pass - reverse a NEGATIVE integer
    reverseInt(${intToReverse})
    ${expectedAndReceived}`);
    } else {
    console.error(`FAIL - reverse a NEGATIVE integer
    reverseInt(${intToReverse})
    ${expectedAndReceived}`);
    }

  • @salaminipples965
    @salaminipples965 2 месяца назад

    These are way easier than "easy" leetcode problems.

  • @petehotchkiss4830
    @petehotchkiss4830 2 месяца назад

    Does the capitalise method need to split strings out? Would it not be more performant to use a RegEx for this?
    eg
    const capitalise = (str): string =>
    str.replace(/\w\S*/g, (s) => `${s.charAt(0).toUpperCase()}${s.slice(1).toLowerCase()}`);

  • @HazimTulumovic
    @HazimTulumovic 12 дней назад

    Max chars:
    function maxChar(str) {
    const usedChars = {};
    for (const char of str) {
    usedChars[char] = usedChars[char] ? usedChars[char] + 1 : 1;
    }
    return Object.keys(usedChars).sort((a, b) => usedChars[b] - usedChars[a])[0];
    }