Arrays - Data Structures and Algorithms in Javascript | Frontend DSA Interview Questions

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ก.ค. 2024
  • ➡️ Download my DSA with JS E-Book - topmate.io/roadsidecoder/491565
    ➡️ Book an Interview Preparation call with me - topmate.io/roadsidecoder
    In this video, we will dive into Array methods in JavaScript and explore their various use cases. We will also discuss commonly DSA interview questions related to Arrays and how to solve them using JavaScript.
    This is the most Entertaining and Knowledge Packed Data Structures and Algorithms in Javascript Interview Course on TH-cam !
    #javascriptinterviewquestions #datastructures #datastructuresandalgorithms
    🟦 Follow me on Twitter and u will clear your interview 🤓 -
    / piyush_eon
    ➡️ Source Code -
    github.com/piyush-eon/dsa-wit...
    📄 Homework Questions ( I will make videos on these questions as well ) -
    leetcode.com/problems/move-ze...
    leetcode.com/problems/maximum...
    leetcode.com/problems/contain...
    leetcode.com/problems/interse...
    🔗 Complete Data Structures and Algorithms with JS Course -
    • Data Structures and Al...
    🔗 Big O Notation Video -
    • Big O Notation - Data ...
    🔗 Functions Video -
    • Javascript Interview Q...
    🔗 Map, filter and reducr video -
    • Javascript Interview Q...
    🔗 Frontend Machine Coding Interview Series -
    • Frontend Machine Codin...
    🔗 Cars24 Interview Experience -
    • Frontend Interview Exp...
    🔗 Unacademy Interview Experience -
    • Frontend Interview Exp...
    🔗 Tazorpay Interview Experience -
    • Frontend Interview Exp...
    🔗 MERN Stack Tutorial with Redux -
    • MERN Stack Project Tut...
    🔗 React Beginner's Project Tutorials -
    • React JS Project Tutor...
    -------------------------------------------------------------------------
    00:00:00 Intro
    00:00:54 Creating an Array
    00:01:34 Initializing an Array
    00:02:24 What all can array store?
    00:03:24 Array length Property
    00:03:54 Add / Remove items in Array
    00:03:58 Push and Pop method
    00:05:32 shift and unshift method
    00:06:29 Looping the Arrays
    00:06:49 "for" loop
    00:07:37 "while" loop
    00:08:09 Inbuilt Traversal Methods
    00:08:25 map() in Arrays
    00:10:14 filter() in Arrays
    00:10:59 reduce() in Arrays
    00:12:55 some() in Arrays
    00:13:25 every() in Arrays
    00:14:01 find() in Arrays
    00:14:42 Spread and Rest Operators
    00:17:51 More Array Methods
    00:17:56 concat() in Arrays
    00:19:19 slice() in Arrays
    00:21:13 splice() in Arrays
    00:22:47 fill() in Arrays
    00:23:58 findIndex() in Arrays
    00:25:09 flat() in Arrays
    00:26:19 Technical Glitch
    00:26:48 reverse() in Arrays
    00:27:18 sort() in Arrays
    00:29:44 DSA Interview Questions on Array in Javascript
    00:29:50 Ques 1 - Second Largest Number
    00:30:28 Solution #1 - Brute Force Approach
    00:34:46 Time Complexity of this Algorithm
    00:36:33 Solution #2 - Optimised Approach
    00:39:30 Explanation of Solution #2
    00:41:29 Time Complexity of this Algorithm
    00:42:26 Space Complexity of this Algorithm
    00:42:49 Ques 2 - Rotate Array by K
    00:43:51 Solution #1 - Using Inbuilt JS Functions
    00:48:40 Time Complexity of this Algorithm
    00:49:24 Solution #2 - Without Inbuilt Functions
    00:56:26 Time Complexity of this Algorithm
    00:57:29 Space Complexity of this Algorithm
    00:58:16 Ques 3 - Remove Duplicates from Sorted Array
    00:59:20 Solution #1 - With Inbuilt JS Methods
    01:03:08 Time Complexity of this Algorithm
    01:03:32 Space Complexity of this Algorithm
    01:03:41 Solution #2 - Two Pointer Approach
    01:07:28 Explanation of above algorithm
    01:10:22 Time / Space Complexity of this Algorithm
    -------------------------------------------------------------------------
    ⭐ Support the channel and learn from me One on One -
    / @roadsidecoder
    Special Thanks to our members -

ความคิดเห็น • 118

  • @RoadsideCoder
    @RoadsideCoder  ปีที่แล้ว +13

    🔴 Get my Complete Frontend Interview Prep course - roadsidecoder.com/course-details
    ➡ Download my DSA with JS E-Book - topmate.io/roadsidecoder/491565
    ✅ Follow me on Instagram to be updated about next videos - instagram.com/roadsidecoder/
    If this video gets good response, I will make more DSA videos, so do share it with others 🔥

  • @shivamkumar-zz1kp
    @shivamkumar-zz1kp ปีที่แล้ว +33

    please please please dont quit this course....please keep uploading

  • @VarunKapoor-tc1je
    @VarunKapoor-tc1je ปีที่แล้ว +1

    thanks bro . we really needed quality dsa guidance in Javascript

  • @purusharma8192
    @purusharma8192 ปีที่แล้ว +2

    Wow,ab to video aur acchi hoti ja rahi hai day by day

  • @Android-17
    @Android-17 ปีที่แล้ว +12

    Excellent session!
    Looking forward to the whole series.
    Also,
    #FreeAlgoAgarwal 🚩

  • @ashishmadan5700
    @ashishmadan5700 10 หลายเดือนก่อน

    Very knowledgable content , almost all my approaches are similar to yours !! ❤😎

  • @avinashgardasalgonquin4371
    @avinashgardasalgonquin4371 ปีที่แล้ว +1

    Bro, thanks a lot for making this video. I've been waiting to watch a tutorial that covers most of the functions with arrays.

  • @BharathKumar-iq7ku
    @BharathKumar-iq7ku ปีที่แล้ว

    Thanks buddy appreciate it.. Keep doing the good work!!! ❤✨

  • @Arifhossain-fk3ub
    @Arifhossain-fk3ub ปีที่แล้ว

    eagerly waiting for next videos

  • @shubhamsharaff6358
    @shubhamsharaff6358 ปีที่แล้ว +2

    Hats off to you man ❤ , the way you're explaining is so simple to understand any methods in this array video

  • @sanvijha
    @sanvijha ปีที่แล้ว

    Great explained thank you

  • @ajitpatil7214
    @ajitpatil7214 ปีที่แล้ว +1

    Thumbnail is very good 🔥 and also the concepts are well explained in organised manner. Problems on those concepts make more understanding.

  • @ThelookAt
    @ThelookAt ปีที่แล้ว +2

    Khatrnak bhaii.. All array clear in one video my frnd also thx me for your video🎉❤

    • @rakibhassan3575
      @rakibhassan3575 ปีที่แล้ว

      can anyone explain if secondLargest ([2, 3, 44, 5, 44, 3, 7, 8, 11]) in the arr the optimised code will give 44 as second largest
      During the fifth iteration, the value of arr[i] is 44, which is equal to the current value of largest. Therefore, the else if condition is true, and the value of secLar is updated to the current value of largest, which is 44. The value of largest remains 44.
      During the sixth iteration, the value of arr[i] is 3, which is smaller than largest. The else if condition is also false, so nothing happens.
      During the seventh iteration, the value of arr[i] is 7, which is smaller than largest. The else if condition is also false, so nothing happens.
      During the eighth iteration, the value of arr[i] is 8, which is smaller than largest. The else if condition is also false, so nothing happens.
      In the ninth iteration, the largest value is 44 (which was updated during the eighth iteration), and the current value of arr[i] is 11, which is smaller than both the current largest and second-largest values. Therefore, there are no updates made to the values of largest or secLar during this iteration.

  • @user-hu1sh4je3m
    @user-hu1sh4je3m หลายเดือนก่อน

    ✨Nice Explaintion of the and logic its very helpful plz do such videos thank you fpr knowledge✨

  • @lucaliebenberg7565
    @lucaliebenberg7565 ปีที่แล้ว +9

    Great content, would be awesome if you could upload more and continue with DSA's (going into string manipulation and potentially some common toy problems in JS!) 🙏👑
    #FreeAlgoAgarwal

    • @rakibhassan3575
      @rakibhassan3575 ปีที่แล้ว

      can anyone explain if secondLargest ([2, 3, 44, 5, 44, 3, 7, 8, 11]) in the arr the optimised code will give 44 as second largest
      During the fifth iteration, the value of arr[i] is 44, which is equal to the current value of largest. Therefore, the else if condition is true, and the value of secLar is updated to the current value of largest, which is 44. The value of largest remains 44.
      During the sixth iteration, the value of arr[i] is 3, which is smaller than largest. The else if condition is also false, so nothing happens.
      During the seventh iteration, the value of arr[i] is 7, which is smaller than largest. The else if condition is also false, so nothing happens.
      During the eighth iteration, the value of arr[i] is 8, which is smaller than largest. The else if condition is also false, so nothing happens.
      In the ninth iteration, the largest value is 44 (which was updated during the eighth iteration), and the current value of arr[i] is 11, which is smaller than both the current largest and second-largest values. Therefore, there are no updates made to the values of largest or secLar during this iteration.

  • @gauravdhenge6328
    @gauravdhenge6328 ปีที่แล้ว +1

    Thank you so much brother your all videos are very needful...!!!

  • @harikrishnanpandyan5684
    @harikrishnanpandyan5684 ปีที่แล้ว

    More same like this video please.,.. 🔥🔥🔥🔥🔥🔥

  • @dipalikumari7777
    @dipalikumari7777 ปีที่แล้ว +3

    best video..please continue this great work

  • @moses3544
    @moses3544 ปีที่แล้ว

    I have a MERN app with Frontend and Backend, I am having trouble with Axios when I deployed the app to Amazon Web Service (EC2). Have you encountered this with Axios?

  • @TufailAkram-pe5fm
    @TufailAkram-pe5fm ปีที่แล้ว

    Brother please upload further, your videos are very helpful and we'll explained.

    • @rakibhassan3575
      @rakibhassan3575 ปีที่แล้ว

      can anyone explain if secondLargest ([2, 3, 44, 5, 44, 3, 7, 8, 11]) in the arr the optimised code will give 44 as second largest
      During the fifth iteration, the value of arr[i] is 44, which is equal to the current value of largest. Therefore, the else if condition is true, and the value of secLar is updated to the current value of largest, which is 44. The value of largest remains 44.
      During the sixth iteration, the value of arr[i] is 3, which is smaller than largest. The else if condition is also false, so nothing happens.
      During the seventh iteration, the value of arr[i] is 7, which is smaller than largest. The else if condition is also false, so nothing happens.
      During the eighth iteration, the value of arr[i] is 8, which is smaller than largest. The else if condition is also false, so nothing happens.
      In the ninth iteration, the largest value is 44 (which was updated during the eighth iteration), and the current value of arr[i] is 11, which is smaller than both the current largest and second-largest values. Therefore, there are no updates made to the values of largest or secLar during this iteration.

  • @VivekYadav-sv7nj
    @VivekYadav-sv7nj 4 หลายเดือนก่อน

    In your last question 's first method how array.splice() can have constant time complexity as splice() itself is of linear time complexity ?

  • @padmatalla9371
    @padmatalla9371 3 หลายเดือนก่อน

    Please please make more such videos.....🙏🙏🙏🙏

  • @wizzy4240
    @wizzy4240 6 หลายเดือนก่อน

    Moving forward from that joke was a better decision than anything else

  • @damandeepsingh4186
    @damandeepsingh4186 10 วันที่ผ่านมา

    // Ques 2 - Rotate Array by K
    // Given an integer array nums, rotate the array to the right by k steps,
    // where k is non - negative.
    // Input: nums = [1,2,3,4,5,6,71, k = 3
    // Input: nums = (-1, -100,3,99], k = 2Output: [5,6,7,1,2,3,4]Output: [3,99,-1, -100]
    solution :
    function rotateIT(nums, a) {
    for (let i = 0; i < a; i++) {
    nums.unshift(nums.pop());
    }
    return nums;
    }
    let num1 = [1, 2, 3, 4, 5, 6, 7]
    let num2 = [-1, -22, 33, 4 - 2]
    console.log(rotateIT(num1, 3));

  • @kinder-krish
    @kinder-krish ปีที่แล้ว

    Bro , last vedio which is Remove duplicate form array ,last program output for length giving crt answer...if u print sorted array it is giving a wrong output

  • @midunc5317
    @midunc5317 ปีที่แล้ว

    Why are we giving size-k,size in splice ? 49:47 we can give size-k,k right?

  • @mehr4294
    @mehr4294 ปีที่แล้ว +1

    Can we have problem solving based on dsa

  • @tpadma7419
    @tpadma7419 3 หลายเดือนก่อน

    I have purchased DSA JS e-Book, really helpful...direct links to leetcode....thank you for preparing eBook.....

    • @RoadsideCoder
      @RoadsideCoder  3 หลายเดือนก่อน

      Awesome, thank you!

  • @parassharma7041
    @parassharma7041 ปีที่แล้ว

    Best video❤

  • @dayachettri5157
    @dayachettri5157 ปีที่แล้ว

    Thankyou very much ❣

  • @watchtube9429
    @watchtube9429 ปีที่แล้ว +3

    ok bro but please upload the full course we are waiting

  • @ShubhamKumar-dc9tu
    @ShubhamKumar-dc9tu ปีที่แล้ว

    Plzz Bhaiya add more videos and String question video 🙏🙏

  • @padmatalla9371
    @padmatalla9371 3 หลายเดือนก่อน

    So indepth and crystal clear explanation....🎉

    • @RoadsideCoder
      @RoadsideCoder  3 หลายเดือนก่อน

      You can check my complete course for more - roadsidecoder.com/course-details

    • @padmatalla9371
      @padmatalla9371 3 หลายเดือนก่อน

      @@RoadsideCoder purchased complete course

    • @padmatalla9371
      @padmatalla9371 3 หลายเดือนก่อน

      @@RoadsideCoder really helpfull interview guide to crack interviews

  • @ask8573
    @ask8573 11 หลายเดือนก่อน

    Array in JS is different from core Data structures Array, in js array is a special object.

  • @show_me_the_moneyy
    @show_me_the_moneyy ปีที่แล้ว

    Would like to see algo Agarwal conduct one session -

  • @ayushtiwari9343
    @ayushtiwari9343 7 หลายเดือนก่อน

    In your 2'nd problem your approach is not working if the k is >= 2*array.length please check if it's okay or not

  • @MEGHU2317
    @MEGHU2317 4 หลายเดือนก่อน

    Can you please also add multidimensional array compare, iterate

  • @tarundurbha5398
    @tarundurbha5398 ปีที่แล้ว

    Bro please do this DSA series for string and object as well plz bro 😀

  • @mohd.furqanali9064
    @mohd.furqanali9064 ปีที่แล้ว

    Bring Strong questions as well

  • @KevinGonzalez-xj4ur
    @KevinGonzalez-xj4ur ปีที่แล้ว

    because it popped its back?

  • @kedarkulkarni0074
    @kedarkulkarni0074 ปีที่แล้ว +4

    Please make strings problems they really help in interview as well as general coding

  • @ayushmann5897
    @ayushmann5897 ปีที่แล้ว

    bro if possible ,please increase your upload frequency, :)

  • @aaryanpinto9276
    @aaryanpinto9276 ปีที่แล้ว

    Hi Sir I am building your Chat application but I have seen that people are having issues with deployment. Can you create a video on just the deployment part or suggest me an alternative

    • @rakibhassan3575
      @rakibhassan3575 ปีที่แล้ว

      can anyone explain if secondLargest ([2, 3, 44, 5, 44, 3, 7, 8, 11]) in the arr the optimised code will give 44 as second largest
      During the fifth iteration, the value of arr[i] is 44, which is equal to the current value of largest. Therefore, the else if condition is true, and the value of secLar is updated to the current value of largest, which is 44. The value of largest remains 44.
      During the sixth iteration, the value of arr[i] is 3, which is smaller than largest. The else if condition is also false, so nothing happens.
      During the seventh iteration, the value of arr[i] is 7, which is smaller than largest. The else if condition is also false, so nothing happens.
      During the eighth iteration, the value of arr[i] is 8, which is smaller than largest. The else if condition is also false, so nothing happens.
      In the ninth iteration, the largest value is 44 (which was updated during the eighth iteration), and the current value of arr[i] is 11, which is smaller than both the current largest and second-largest values. Therefore, there are no updates made to the values of largest or secLar during this iteration.

  • @tarundurbha5398
    @tarundurbha5398 ปีที่แล้ว

    Bro plz do this DSA series for objects and strings plzz😢

  • @jadeyu4367
    @jadeyu4367 6 หลายเดือนก่อน

    Can you make more of this kind of videos? Array , object exercises

    • @RoadsideCoder
      @RoadsideCoder  6 หลายเดือนก่อน

      already have, you can check on my channel

  • @tusharutane8031
    @tusharutane8031 ปีที่แล้ว +3

    Bhaiya, please late dal rhe ho chalega but finish kar dena bhot courses pade hai Jo kabhi complete he nhi hue 🫠hats off to work you did till now🤩

    • @RoadsideCoder
      @RoadsideCoder  ปีที่แล้ว +4

      I promise to bring you all the most high quality DSA with JS content on youtube. Plus this video will be 1 hour+ so even if its late, I will cover most things in one video, so u all get maximum value!

  • @VinitVinit-ts5nh
    @VinitVinit-ts5nh ปีที่แล้ว

    Bhai please course ko complete karna

  • @purusharma8192
    @purusharma8192 ปีที่แล้ว

    Waiting

  • @hotlyf8609
    @hotlyf8609 ปีที่แล้ว

    Hey Piyush, can you please make a video on how we can send file to that chat application like image, pdf and zip file and the message seen this will add more value to that application.

    • @rakibhassan3575
      @rakibhassan3575 ปีที่แล้ว

      can anyone explain if secondLargest ([2, 3, 44, 5, 44, 3, 7, 8, 11]) in the arr the optimised code will give 44 as second largest
      During the fifth iteration, the value of arr[i] is 44, which is equal to the current value of largest. Therefore, the else if condition is true, and the value of secLar is updated to the current value of largest, which is 44. The value of largest remains 44.
      During the sixth iteration, the value of arr[i] is 3, which is smaller than largest. The else if condition is also false, so nothing happens.
      During the seventh iteration, the value of arr[i] is 7, which is smaller than largest. The else if condition is also false, so nothing happens.
      During the eighth iteration, the value of arr[i] is 8, which is smaller than largest. The else if condition is also false, so nothing happens.
      In the ninth iteration, the largest value is 44 (which was updated during the eighth iteration), and the current value of arr[i] is 11, which is smaller than both the current largest and second-largest values. Therefore, there are no updates made to the values of largest or secLar during this iteration.

  • @santoshmore2953
    @santoshmore2953 ปีที่แล้ว

    bro next video on strings

  • @shivamgoyal796
    @shivamgoyal796 10 หลายเดือนก่อน

    is JS will not work for Faang Companies as small community and and not so much resources available or i continue JS with DS.

    • @RoadsideCoder
      @RoadsideCoder  10 หลายเดือนก่อน +1

      For FAANG companies, comtinue JS with DSA

    • @shivamgoyal796
      @shivamgoyal796 10 หลายเดือนก่อน

      @@RoadsideCoder thanks keep posting video on DSA more and more 😄

  • @Abhi1793
    @Abhi1793 2 หลายเดือนก่อน

    brother can we use this instead of that whole big code
    function check (arr){
    return arr.sort((a,b)=> b-a)[1]
    }
    console.log(check([1,2,3,1]))

    • @RoadsideCoder
      @RoadsideCoder  2 หลายเดือนก่อน

      not allowed in interviews

    • @Abhi1793
      @Abhi1793 2 หลายเดือนก่อน

      @@RoadsideCoder but if i apply in a company where they want javascript and they are paying 25 k a month then it’s applicable?

  • @A9kit.k
    @A9kit.k ปีที่แล้ว

    Piyush brother, please make videos on linked list also

    • @rakibhassan3575
      @rakibhassan3575 ปีที่แล้ว

      can anyone explain if secondLargest ([2, 3, 44, 5, 44, 3, 7, 8, 11]) in the arr the optimised code will give 44 as second largest
      During the fifth iteration, the value of arr[i] is 44, which is equal to the current value of largest. Therefore, the else if condition is true, and the value of secLar is updated to the current value of largest, which is 44. The value of largest remains 44.
      During the sixth iteration, the value of arr[i] is 3, which is smaller than largest. The else if condition is also false, so nothing happens.
      During the seventh iteration, the value of arr[i] is 7, which is smaller than largest. The else if condition is also false, so nothing happens.
      During the eighth iteration, the value of arr[i] is 8, which is smaller than largest. The else if condition is also false, so nothing happens.
      In the ninth iteration, the largest value is 44 (which was updated during the eighth iteration), and the current value of arr[i] is 11, which is smaller than both the current largest and second-largest values. Therefore, there are no updates made to the values of largest or secLar during this iteration.

  • @aaryanpinto9276
    @aaryanpinto9276 ปีที่แล้ว +1

    Hi brother I'm going to start your Chat application playlist. The Application is just God level. But if I download the versions which you have installed and start developing will everything work fine. Tell me if I'm good to go

    • @RoadsideCoder
      @RoadsideCoder  ปีที่แล้ว

      Yes it will work fine!

    • @aaryanpinto9276
      @aaryanpinto9276 ปีที่แล้ว

      @@RoadsideCoder OK word!! Starting it today itself

  • @SoorajJose1
    @SoorajJose1 ปีที่แล้ว +2

    46:22 how the length of array become 8 ,as you mentioned in video arr = [1,2,3,4,5,6,7] . it is 7 ryt ?

    • @krishnat9767
      @krishnat9767 ปีที่แล้ว +1

      Also the index count should start from zero instead of one

    • @VimalKumar-cc2ri
      @VimalKumar-cc2ri 10 หลายเดือนก่อน

      ​@@krishnat9767the it should be 6 right?

    • @VishalSanap-qj4zn
      @VishalSanap-qj4zn 5 หลายเดือนก่อน

      Length of an array is the no. of elements and indexes start from 0. so length should be 7 and no of indexes should be 6 - [0,1,2,3,4,5,6]

    • @guptasagar694
      @guptasagar694 หลายเดือนก่อน

      Yehi toh...Galat bataya usne solution 1 and optimised raw wala bhi...Yaar isko zyada knowledge nahi he...

  • @rishiraj2548
    @rishiraj2548 ปีที่แล้ว

    Good day greetings

  • @parassingh9723
    @parassingh9723 ปีที่แล้ว

    🙏

  • @awais_ansarii
    @awais_ansarii 10 หลายเดือนก่อน

  • @rakibhassan3575
    @rakibhassan3575 ปีที่แล้ว +1

    can anyone explain if secondLargest ([2, 3, 44, 5, 44, 3, 7, 8, 11]) in the arr the optimised code will give 44 as second largest
    During the fifth iteration, the value of arr[i] is 44, which is equal to the current value of largest. Therefore, the else if condition is true, and the value of secLar is updated to the current value of largest, which is 44. The value of largest remains 44.
    During the sixth iteration, the value of arr[i] is 3, which is smaller than largest. The else if condition is also false, so nothing happens.
    During the seventh iteration, the value of arr[i] is 7, which is smaller than largest. The else if condition is also false, so nothing happens.
    During the eighth iteration, the value of arr[i] is 8, which is smaller than largest. The else if condition is also false, so nothing happens.
    In the ninth iteration, the largest value is 44 (which was updated during the eighth iteration), and the current value of arr[i] is 11, which is smaller than both the current largest and second-largest values. Therefore, there are no updates made to the values of largest or secLar during this iteration.

    • @salmanfisal9446
      @salmanfisal9446 ปีที่แล้ว

      you have wrongly understood the problem in the if else(arr[i] !== firstlargest ) which means in the third index the 44 is overwritten by the immediate value of an array and those the immediate value we will compare with the arr[i] thats the reason we provided else if(arr[i] !==firstlargest ) i think you forget to enter "!" operator in the edge case statement

  • @SUVADEEPMAITY
    @SUVADEEPMAITY ปีที่แล้ว +1

    Next video on objects please 🥺🙏

    • @RoadsideCoder
      @RoadsideCoder  ปีที่แล้ว +1

      Already made - th-cam.com/video/XnFIX3c7xoI/w-d-xo.html

    • @SUVADEEPMAITY
      @SUVADEEPMAITY ปีที่แล้ว +1

      @@RoadsideCoder oh great.. Is it covering all the topics? And thank you so much for all these videos

  • @funtrap2289
    @funtrap2289 ปีที่แล้ว +1

    Many ytubers started DSA playlists but no one complete all topics
    Because they got subscribers so they will start collaboration vedio😢

    • @RoadsideCoder
      @RoadsideCoder  ปีที่แล้ว

      Don't worry, I will complete it fully!

  • @vishnusingh2300
    @vishnusingh2300 ปีที่แล้ว

    29:00

  • @nicet7330
    @nicet7330 ปีที่แล้ว +1

    Bro love you ❤❤.

  • @damandeepsingh4186
    @damandeepsingh4186 11 วันที่ผ่านมา

    //Ques 1 - Second Largest Number
    // Given an array Arr of size N, print second largest
    // distinct element from an array.
    // Input: [12, 35, 1, 10, 34, 1]
    // Input: [10, 5, 10] ->>›››Output: 34 Output: 5
    let aa = [12, 35, 11, 10, 34, 1]
    let q = [10, 5, 10]
    let UNiq = q.filter((value, index, self) => self.indexOf(value) === index)
    let bb = aa.sort((a, b) => a - b)
    let c = bb[bb.length - 2]
    let DD = UNiq.sort((a, b) => a - b)
    let d = DD[DD.length - 2]
    console.log(c)
    console.log(d)

    • @damandeepsingh4186
      @damandeepsingh4186 11 วันที่ผ่านมา

      //with function
      let aa = [12, 35, 11, 10, 34, 35, 1]
      let q = [10, 5, 10]
      function sortIng(arr) {
      let uniquearr = arr.filter((value, index, self) => self.indexOf(value) === index)
      uniquearr.sort((a, b) => a - b);
      if (uniquearr.length < 2) {
      return null;
      }
      return uniquearr[uniquearr.length - 2];
      }
      let bbb = sortIng(aa);
      let bbb2 = sortIng(q);
      console.log(bbb);
      console.log(bbb2);

  • @KishanKumar-vl9dr
    @KishanKumar-vl9dr 7 หลายเดือนก่อน

    // More efficiennt solution for second max.
    let arr=[10,0,90];
    function secondMax(arr){
    let max= arr[0];
    let secondMax = -Infinity;
    for(let i=1; i max){
    secondMax = max;
    max = arr[i];
    }else if(arr[i] >secondMax && arr[i] < max) {
    secondMax = arr[i];
    }
    }
    return secondMax;
    }
    console.log(secondMax(arr));

  • @vishnusingh2300
    @vishnusingh2300 ปีที่แล้ว

    45:34

  • @anurag.rathore31
    @anurag.rathore31 11 หลายเดือนก่อน +1

    👇More optimised code 👇
    function secondLar(arr) {
    let max= Number.NEGATIVE_INFINITY;
    let secondMax=Number.NEGATIVE_INFINITY;
    for(let i=0; i max){
    secondMax=max;
    max= arr[i];
    }
    }
    return secondMax;
    }

    • @anurag.rathore31
      @anurag.rathore31 11 หลายเดือนก่อน

      No need of else if condition

    • @raiga98
      @raiga98 11 หลายเดือนก่อน

      This isn't correct. What if you had array of the following: [4,7,6,5,2 1]. The second largest would be 6, but this code would return 4. That's why the second if statement is needed. In his first if statement however, he should've set secondLargest before updating the largest though because doing it the way he did it will cause both variables to store the dame value.

    • @anurag.rathore31
      @anurag.rathore31 11 หลายเดือนก่อน

      @@raiga98 yes, that's for an edge case.

  • @premsingh6967
    @premsingh6967 ปีที่แล้ว

  • @tpadma7419
    @tpadma7419 3 หลายเดือนก่อน

    ya javascript got tired of doing Push'up'

  • @sumanthprabhu11
    @sumanthprabhu11 ปีที่แล้ว +1

    un-optimized solutions are the easiest to understand

    • @rakibhassan3575
      @rakibhassan3575 ปีที่แล้ว

      can anyone explain if secondLargest ([2, 3, 44, 5, 44, 3, 7, 8, 11]) in the arr the optimised code will give 44 as second largest
      During the fifth iteration, the value of arr[i] is 44, which is equal to the current value of largest. Therefore, the else if condition is true, and the value of secLar is updated to the current value of largest, which is 44. The value of largest remains 44.
      During the sixth iteration, the value of arr[i] is 3, which is smaller than largest. The else if condition is also false, so nothing happens.
      During the seventh iteration, the value of arr[i] is 7, which is smaller than largest. The else if condition is also false, so nothing happens.
      During the eighth iteration, the value of arr[i] is 8, which is smaller than largest. The else if condition is also false, so nothing happens.
      In the ninth iteration, the largest value is 44 (which was updated during the eighth iteration), and the current value of arr[i] is 11, which is smaller than both the current largest and second-largest values. Therefore, there are no updates made to the values of largest or secLar during this iteration.

  • @saikatbishal8429
    @saikatbishal8429 ปีที่แล้ว

    Lame joke but great video.

  • @joshuaajagbe5096
    @joshuaajagbe5096 ปีที่แล้ว

    Hi guys

  • @CS_HimanshuVishwakarma
    @CS_HimanshuVishwakarma 9 หลายเดือนก่อน

    This playlist is not for beginners

  • @SCRIPTSAG
    @SCRIPTSAG ปีที่แล้ว

    Why you gyus just make a video without board and pen 🖊️ with I think I need to creat a video beacuse of awo kuch bhi bna do Bina ache se samghye

    • @RoadsideCoder
      @RoadsideCoder  ปีที่แล้ว

      Ok from next video I will use it!

  • @charankumarbasam5866
    @charankumarbasam5866 ปีที่แล้ว

    function Rotation( arrayRot, k){
    return arrayRot= [...arrayRot.slice(arrayRot.length-k,arrayRot.length),...arrayRot.slice(0,arrayRot.length-k)]
    }

  • @VinitVinit-ts5nh
    @VinitVinit-ts5nh ปีที่แล้ว

    Bhai please course ko complete karna