Capgemini Java Coding Interview Question Answers

preview_player
Показать описание
In this video, we solved Java Coding Interview Question which was asked in Capgemini Interview. The candidate had 2 Years of Experience working as a Java Developer, He solved the problem and got selected with CTC of 8 LPA.

#leetcode
#java
#interview
#javaprogramming
#javacoding
#javainterviewquestions
#CapgeminiInterviewQuestions

For Complete Java Interview Preparation Watch this Playlist:
Рекомендации по теме
Комментарии
Автор

TimeComplexity of this code is O(array1.length)+O(array2.length)+O(mergeArray.length*log(mergeArray.length)), it looks like simple but internally lot of things are happening. In the interviews follow your methods instead of going with predefined.

Note: printing shouldn't be counted while calculating the timeComplexity.

Try this: TImeComplexity is O(joinedArray.length).

public static void main(String[] args) {
int[] a = { 10, 20, 30, 40, 50 };
int[] b = { 9, 18, 27, 36, 45 };

int joinedArray[] = new int[a.length + b.length];

int i = 0, j = 0, k = 0;

while (i < a.length && j < b.length) {
if (a[i] < b[j]) {
joinedArray[k++] = a[i++];
} else if (a[i] == b[j]) {
joinedArray[k] = a[i++];
joinedArray[++k] = b[j++];
k++;
} else {
joinedArray[k++] = b[j++];
}
}
if (i < a.length) {
joinedArray[k] = a[i];
i++;
k++;
}
if (j < b.length) {
joinedArray[k] = b[j];
j++;
k++;
}

for (int m : joinedArray) {
System.out.println(m);
}

}

nanisai
Автор

nice video brother, please make video on graph and tree ques also like eg-> if two arrays are given check if it is cyclic graph or not please make video on this also.

utkarshshukla
Автор

Instead of sort method I think in interview merge approach will be better

omkarrasal
Автор

It would look much better if your eclipse is in dark mode.

shashankkatturwar