Home / Expert Answers / Computer Science / solve-this-question-with-the-complexity-of-o-n-given-two-integer-array-nums-of-distinct-i-pa615

(Solved): Solve this question with the complexity of \( O\{n\} \) Given Two integer array nums of distinct i ...



Solve this question with the complexity of \( O\{n\} \)
Given Two integer array nums of distinct items and a target value.
Re

Solve this question with the complexity of \( O\{n\} \) Given Two integer array nums of distinct items and a target value. Return the index for both arrays when the difference between elements is equal to the target value if there is no item in both array whose difference is equal to the target then return \( [-1,-1] \) Example 1: Input: numsFirst \( =[3,4,10] \) Input: numsSecond \( =[1,4,8] \) Input: target \( =5 \) Output: nums \( =[0,2] \) eg: 8 from numsSecond - 3 from numFirst is equal to 5 which is target Example 2: Input: numsFirst \( =[2,4,10] \) Input: numsSecond \( =[1,4,8] \) Input: target \( =5 \) Output: nums \( =[-1,-1] \)


We have an Answer from Expert

View Expert Answer

Expert Answer


Here is your Java solution in O(n) time complexity , Check it out! Code import java.util.*; public class Main { public static void main(String[] args) { int []arr1 = {2,4,10}; int []arr2 = {1,4,8}; int tar
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe