Java 8 Q&A | 🔥 Asked in Myntra | Find Nth Highest Salary Using Java Streams API | JavaTechie

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

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

  • @purnasahu8766
    @purnasahu8766 Год назад +22

    Excellent, plz bring such new types of java coding questions in your upcoming videos...

  • @sreetmi1918
    @sreetmi1918 Год назад +3

    this is really good video for those who are lagging in doing programming with corejava.... if any one practice this and learn doing on their own..they ll start become stronger and stronger intheir coding skillls... thanks for the good work..

  • @kshitijbansal3672
    @kshitijbansal3672 Год назад +3

    Sir, I cant thank you more, today I had 2nd technical round with TechM, the interviewer asked the same question, that how you will group male and female on the basis of dept. but you are getting the Dept. name as a method argument. I randomly watched this video 3-4 days back and today when interviewer asked this question, I could only think about this video and provided him the solution in a minute.

    • @Javatechie
      @Javatechie  Год назад

      Glad to hear this buddy 🥰🥰. Keep learning 😃

    • @rushikeshgodase4150
      @rushikeshgodase4150 Год назад

      Your experience. How much package they offered??

  • @tanson86
    @tanson86 Год назад +4

    Nice incremental way of teaching streams in general.

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

    for me remembering the entire syntax is tough. I don't know how would someone memorize the entire syntax and get the expected result LOL😇
    Thank you Basant for creating amazing content!

  • @charliegamboa9567
    @charliegamboa9567 Год назад +4

    What a useful content and example. Thanks for sharing

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

    Thank Your very Much sir. Many programmers are learn more knowledge by yours videos.

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

    Hello Sir,
    Pls explain this interview question
    int[] numbers = {1, 5, 7, -1, 5}
    out put is (1,5),(7,-1),(5,1) and combination is 3

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

      Here combination is 6 right? You need to figure out pair whose sum is given input

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

    In output we got the map has key salary and value name, but if I want same map in which key is name and salary is value is it possible?

  • @yatendra__singh
    @yatendra__singh Год назад +2

    After watching these kind of videos from you ...i am just thinking how some one like you❤ got this much of depth knowledge in java ... could you please explain me in one word??

    • @PKKCAD
      @PKKCAD Год назад

      May be he tried multiple times in offline.

    • @Javatechie
      @Javatechie  Год назад +3

      I think the permanent hunger of learning helps everyone , thank you so much for your valuable words.

    • @Javatechie
      @Javatechie  Год назад +3

      Of course Kk , i have tried it and understand the purpose of each line before preparing the video .

    • @sajid.farooqi8074
      @sajid.farooqi8074 Год назад

      @@PKKCAD nothing is without practicing

  • @sajid.farooqi8074
    @sajid.farooqi8074 Год назад +2

    Hi please bring a complete tutorial on multi threading programing. As of no complete vedio tutorial i have found on RUclips.

  • @chiranjib2patra
    @chiranjib2patra 7 месяцев назад +1

    Thats a very good approach to teaching Basanth✌️ Liked it👍 Also would like to suggest if you could add a bigger display then the whole code we might get to see the single screen.

  • @sajid.farooqi8074
    @sajid.farooqi8074 Год назад +1

    Nice way of delivering such complicated looking problem.

  • @sagarjaiswal9451
    @sagarjaiswal9451 Год назад +4

    Optional secondHighestEmployee = employees.stream()
    .collect(Collectors.groupingBy(Employee::getSalary, TreeMap::new, toList()))
    .entrySet()
    .stream()
    .skip(n-1)//
    .map(Map.Entry::getValue)
    .findFirst();
    System.out.println(secondHighestEmployee);

  • @krishnapriya-b7s
    @krishnapriya-b7s 12 дней назад

    Thank you. Could you please explain how to write program for placing n queen in n*n board?

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

    Thanks Basanth.Nice Video. God bless you.

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

    I have made it by the following way Employee nthHighestEmployee = employees.stream()
    .sorted(Comparator.comparingDouble(Employee::getSalary).reversed()).skip(n - 1).findFirst()
    .orElse(null);

    • @Javatechie
      @Javatechie  Год назад

      If multiple employees have the same value will it work ?

    • @rabisankarpodder7839
      @rabisankarpodder7839 Год назад

      @@Javatechie Yes it will take the previous value for 3rd highest salary. e.g . List employees = new ArrayList();
      employees.add(new Employee(101, "John", 5000));
      employees.add(new Employee(102, "Alice", 8000));
      employees.add(new Employee(103, "Bob", 3000));
      employees.add(new Employee(104, "Mary", 6000));
      employees.add(new Employee(105, "Tom", 2000));
      employees.add(new Employee(106, "Jane", 7000));
      employees.add(new Employee(108, "Rabi", 6000));
      employees.add(new Employee(107, "Mike", 4000)); Output:- Employee [empId=104, empName=Mary, salary=6000]

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

    The solution based on sorting is not optimal.
    min/max heaps should be used.
    can the Java Stream API provide the optimal solution based on the min/max heaps?

  • @jairam884
    @jairam884 4 дня назад +1

    Nice

  • @ManojKumar-te5by
    @ManojKumar-te5by Год назад +1

    Can you make an real example of Optional where use some frequent and important methods like OrElseGet() etc

  • @bnayak8039
    @bnayak8039 9 месяцев назад +1

    Hey thank you so much you deserve lasts of appreciation, but I expected not enough from you

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

    Amazing videos for java techies.

  • @YogeshGhode-j5j
    @YogeshGhode-j5j 10 месяцев назад +1

    Hi Sir why you have used "Collections.reverseOrder(Map.Entry.comparingByKey())" insted of "Comparator.comparing(Map.Entry.comparingByKey()).reversed()"

  • @siddharthagrawal4280
    @siddharthagrawal4280 Год назад +2

    I have upcoming interview 2nd round on Friday. I know backend spring boot but am not aware of java 8 and all crucial features and usecases of it, i am told it will be asked for sure.
    Can you please suggest me few sources to understand everything about java 8 from scratch?? Or best make a small playlist if possible.
    Humble request! Could be Life changing for me!

    • @Javatechie
      @Javatechie  Год назад

      It's already there please have a look
      ruclips.net/p/PLVz2XdJiJQxzrdrpglCv_nWIO5CDIqOVj

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

      Completed the playlist!
      It's pure Gem. Thanks man.

    • @raviravi-gg5ck
      @raviravi-gg5ck 10 месяцев назад

      ​@@siddharthagrawal4280 u got selected ?

    • @siddharthagrawal4280
      @siddharthagrawal4280 10 месяцев назад

      @@raviravi-gg5ck yes bro! This is great source for getting industry ready

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

    We want more this kind of videos.

  • @abasahebbhingardeve5464
    @abasahebbhingardeve5464 Год назад

    Kindly make a video on fetching Arrey Index of top 4 records from millions of record in a database.

  • @naincysharma5522
    @naincysharma5522 Год назад

    Even if you cant...no worries..thanks for your efforts in making these videos that are of so much help

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

    Thanks for good content. Hope you keep sharing on((:

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

    Hi ,I have list of employee objects I just want sort my employee list based on name in ascending order age in descending order ,salary in ascending order at a time
    How we make this combine sort ?

    • @Javatechie
      @Javatechie  Год назад

      You need to customize your comparator. There is no direct support given by java 8

  • @immortalhuman7085
    @immortalhuman7085 Год назад

    Can you make video on how to switch from service based company to product based company?

  • @Aman-Thakor
    @Aman-Thakor Год назад +1

    If I'm passing num value gt than size of sorted list, it will fail at get(index). What we can do in that case on streams?

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

      Definitely it will fail, so you need to validate that num

  • @sourabh2635
    @sourabh2635 6 месяцев назад

    Optionalsecodhighest=list.stream().sorted(Comparator.comparing(Employee::getSalary)).skip(3).findFirst();
    sysout(secondhghest) -- is this correct?

  • @user-0987-a
    @user-0987-a Год назад +1

    Big thanks from Africa

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

    Excellent tutorial Bro!! Please keep post solving new problems!!

  • @naincysharma5522
    @naincysharma5522 Год назад +2

    Can you please help on a interview question where they asked to create a person class that has some fields like id, name, address, age etc and there can be 100+ such field in person class.
    We need to write a program to sort the person data using some dynamic criteria, like sample criteria can be
    Id only
    Id+ name
    Name onky
    Age onky
    Id+name+age
    And so on
    Can you help me on this..
    She suggested to use reflection api getdeclaredfield method and getproperty to solve yhis...which i cud not relate to

    • @Javatechie
      @Javatechie  Год назад

      Sure i will check this buddy. Quite interesting

    • @naincysharma5522
      @naincysharma5522 Год назад

      @@Javatechie thank you so much!!

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

    superb content

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

    Awesome 👍

  • @sdash2023
    @sdash2023 Год назад +2

    Sir I LRU and LFU cache using LinkedHashMap please. I failed epam interview because of LFU cache.

  • @punyabikash3624
    @punyabikash3624 7 месяцев назад

    Hello Sir, thank for this 👍👌 i have one question face by Cognizant that there is an array of integers he wanted out put as - { { 1,1,1,1},{2,1,1},{2,2},{3,1} } all possible combination of numbers whose sum is 4 if 4 is passed from console, if i pass 5 then all possible sum and so on could you help to make a video of it...plz

    • @Javatechie
      @Javatechie  7 месяцев назад

      It's very simple you can try the approach below
      import java.util.stream.IntStream;
      public class NumberCombinationSum {
      public static void main(String[] args) {
      int targetSum = 10;
      findCombinations(targetSum);
      }
      public static void findCombinations(int targetSum) {
      IntStream.rangeClosed(1, targetSum / 2)
      .forEach(num1 -> {
      int num2 = targetSum - num1;
      System.out.println(num1 + " + " + num2 + " = " + targetSum);
      });
      }
      }

    • @punyabikash3624
      @punyabikash3624 7 месяцев назад

      Thanks a lot for your Response :) :)
      this is not what he was expecting for example - i will pass 4 from console then output should be - { { 1,1,1,1},{2,1,1},{2,2},{3,1} }
      For example i will pass 5 then output should be - { { 1,1,1,1,1},{2,2,1},{3,2},{4,1} }
      For example i will pass 6 then output should be - { { 1,1,1,1,1,1},{2,2,2},{3,3},{4,2},{5,1} }

    • @Javatechie
      @Javatechie  7 месяцев назад +1

      Ohh okay got it any combination. Will try and update you

  • @bhavanisankar71
    @bhavanisankar71 Год назад

    Sir please tell me how extract Text, table, images data from pdf using java. I am able to extracting text but remaining things how to get please tell me any solution

  • @Anilkumar-reddy
    @Anilkumar-reddy Год назад +1

    Good video bro. Please make a more videos on java8 interview questions

    • @Javatechie
      @Javatechie  Год назад

      Already uploaded buddy please search with keyword interview

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

    Bro realtime project implement action series chey bro

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

    Good one brother

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

    can you please make video on functional interface with recursive?

    • @Javatechie
      @Javatechie  Год назад

      Recursive function class?

    • @krishnan6201
      @krishnan6201 Год назад

      @@Javatechie No Recursive with lambda implementation any logic like factorial given number consider as example.

  • @priyankapatil6783
    @priyankapatil6783 3 месяца назад

    can you please try this find the largest word in a string in java

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

    Thank you

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

    Thanks

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

    Hi bro.. ur videos are more clear. Are you working in software company?

    • @Javatechie
      @Javatechie  Год назад

      Thank you buddy Yes i am a working employee in it

  • @bhargavi4557
    @bhargavi4557 Год назад

    I was asked in a interview How to remove adjacent duplicates of a string in java8

    • @Javatechie
      @Javatechie  Год назад

      Try below approach
      public static String removeAdjacentDuplicates(String input) {
      return input.chars()
      .mapToObj(c -> (char) c)
      .collect(StringBuilder::new, (sb, c) -> {
      if (sb.length() == 0 || sb.charAt(sb.length() - 1) != c) {
      sb.append(c);
      }
      }, StringBuilder::append)
      .toString();
      }

  • @RiskyRishy
    @RiskyRishy Год назад

    great

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

    Good one ❤

  • @pedurujagadish5048
    @pedurujagadish5048 Год назад

    And also debugging process in realtime project chey bro series

    • @Javatechie
      @Javatechie  Год назад

      Please check this link buddy ruclips.net/video/Kon1DGwbtzg/видео.html

  • @PrinceJeniFX
    @PrinceJeniFX 8 месяцев назад

    How many years experience interview was this?

    • @Javatechie
      @Javatechie  8 месяцев назад

      4+, but it can ask a fresher or even can ask to n+ experience

  • @devkratos711
    @devkratos711 10 месяцев назад

    👍

  • @shivAgar2020
    @shivAgar2020 Год назад

    Experience ??

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

    🙏👍

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

    Hello Sir, Nice content and thanks for detailed explanation. I have one question for sorting applied after grouping, Since the map key is Integer than shouldn't this apply sorting by default by using sort() method without passing Comparator implementation? I tried this but it failed and hence I thought to ask here
    ruclips.net/video/eBDN04LlEOg/видео.html

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

      Not getting you buddy could you please elaborate it little bit

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

      @@Javatechie Apologies for confusion. I thought entry set can be sorted by using just sorted() method. It is clear that we need to pass Comparator for sorting of entry set.

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

      Np

  • @66thakur99
    @66thakur99 Год назад +1

    private static Entry getnthHighestSalaryEmployeeName(Map mappedWithSalary, Integer n) {
    return mappedWithSalary.entrySet().stream()
    .sorted(Collections.reverseOrder(Map.Entry.comparingByKey()))
    .skip(n - 1)
    .findFirst()
    .orElse(null);
    }

    • @Javatechie
      @Javatechie  Год назад

      Execute this with different input there is a loop whole

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

    Map dataMap = new HashMap();
    dataMap.put("Bharat",10000);
    dataMap.put("Ram",1200);
    dataMap.put("Laxman",1600);
    dataMap.put("Ravan",4500);
    dataMap.put("Lav",5230);
    Map.Entry nthHighest = dataMap.entrySet().stream()
    .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
    .skip(2)
    .findFirst()
    .get();
    System.out.println(nthHighest); //Can be done this way also

    • @nehasharma-lg3we
      @nehasharma-lg3we Год назад

      It will not consider the case when two people have same salary I guess

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

      Saroj yes if there will be more than 1 employee having the same salary it won't work

  • @kshitijbansal3672
    @kshitijbansal3672 Год назад +17

    Sir, I cant thank you more, today I had 2nd technical round with TechM, the interviewer asked the same question, that how you will group male and female on the basis of dept. but you are getting the Dept. name as a method argument. I randomly watched this video 3-4 days back and today when interviewer asked this question, I could only think about this video and provided him the solution in a minute.

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

      Hi Kshitij,
      What would be the data format to group male and female on the basis of dept?

    • @Sumeshkumarback
      @Sumeshkumarback 3 месяца назад

      You have been placed?