shyam200goyal
BAN USER
Questions (4)
Comments (2)
Reputation 70
- 0of 0 votes
AnswerTell me when you did something beyond client expectations
- shyam200goyal in India| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer - 1of 1 vote
AnswersTell me about when you did something different in your role
- shyam200goyal in India| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
public static void main(String[] args) {
int[] arr1 = {10, 5, 40};
int[] arr2 = {50, 90, 80} ;
int [] first;
int [] second;
int min = Integer.MAX_VALUE;
Arrays.sort(arr1);
Arrays.sort(arr2);
if(arr1.length<arr2.length)
{
first=arr1;
second=arr2;
} else
{
first=arr2;
second=arr1;
}
for (int num : first) {
for (int i = 0; i < second.length; i++) {
int value=Math.abs(num - second[i]);
if (min > value) {
min = value;
}
if (second[i] > num) {
break;
}
}
}
System.out.println(Math.abs(min));
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
public static void main(String[] args) {
- shyam200goyal August 01, 2021int[] arr1 = {10, 5, 40};
int[] arr2 = {50, 90, 80} ;
int [] first;
int [] second;
int min = Integer.MAX_VALUE;
Arrays.sort(arr1);
Arrays.sort(arr2);
if(arr1.length<arr2.length)
{
first=arr1;
second=arr2;
} else
{
first=arr2;
second=arr1;
}
for (int num : first) {
for (int i = 0; i < second.length; i++) {
int value=Math.abs(num - second[i]);
if (min > value) {
min = value;
}
if (second[i] > num) {
break;
}
}
}
System.out.println(Math.abs(min));
}