Given two sorted arrays, Write a java code to find intersection of two arrays.
For example, if the input arrays are:
arr1[] = {2, 3, 6, 7, 9, 11}
arr2[] = {4, 6, 8, 9, 12}
The common elements between these two arrays are {6, 9}.
Given two sorted arrays, Write a java code to find intersection of two arrays.
For example, if the input arrays are:
arr1[] = {2, 3, 6, 7, 9, 11}
arr2[] = {4, 6, 8, 9, 12}
The common elements between these two arrays are {6, 9}.
Given an array of integers, write a code to move all zeroes to end of array. The order of all other elements of an array should be same.
Now, In this question we have to write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.
NOTE : We have to solve this problem in–place without making a copy of the array.
For example –
Example 1:
Input : {1, 2, 0, 4, 0, 5, 3, 8}
Output: {1, 2, 4, 5, 3, 8, 0, 0}
In this example, All zeros are moved to the end of array and the relative order of non-zero elements is also maintained.
Example 2:
Input : {1, 0, 2, 3, 0, 0, 0, 2}
Output : {1, 2, 3, 2, 0, 0, 0, 0}
Write a java program to reverse each word of a string without changing the order of the word..
Suppose, If an input string is Java Programming then the output string should be avaJ gnimmargorP.
Example –
Input: Java Programming
Output: avaJ gnimmargorP