Infosys Java Coding Interview Questions - Day 15

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024
  • In this video, I am going to cover two Java coding interview questions that were asked at Infosys, as shared by someone.
    ---- Problem 1
    // Input:- the mind is what the mind is fed.
    // Output:- the,mind,is
    ----- problem 2
    // input = [0, 6, 3, 2, 4, 0, 0, 2, 0, 5, 0, 0, 1]
    // shift all zero left side
    // output =[0, 0, 0, 0, 0, 0, 3, 2, 2, 5, 4, 6, 1]
    #javainterviewquestion #programming #javaprogrammingonline #coding #java #javacodinginterviewquestions

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

  • @JavaDeveloper-v6o
    @JavaDeveloper-v6o  24 дня назад

    Guys , you can also solve problem number 2 by second approach.
    public static String shift(int[] arr) {
    int i = 0, m = 0;
    while (m < arr.length) {
    if (arr[m] == 0) {
    int val = arr[i];
    arr[i] = arr[m];
    arr[m] = val;
    i++;
    }
    m++;
    }
    return Arrays.toString(arr);
    }
    you should have to try once.