Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5761 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1115 |

@bt8816103042 | 739 |

@thealchemist627 | 456 |

@dalwainazism125 | 453 |

@akashkale117 | 453 |

@shivanandp12345678910 | 453 |

@SherlockHolmes3 | 447 |

@codeantik | 446 |

@SHOAIBVIJAPURE | 430 |

@shalinibhataniya1097 | 408 |

@ShamaKhan1 | 392 |

Complete Leaderboard |

Given two sequences, one is increasing sequence a[] and another a normal sequence b[], find the K-th missing element in the increasing sequence which is not present in the given sequence. If no K-th missing element is there output -1

**Example 1:**

**Input :** Arr[] = {0, 2, 4, 6, 8, 10, 12, 14, 15}
Brr[] = {4, 10, 6, 8, 12}
**Output :** 14
**Explanation:
**The numbers from increasing sequence that
are not present in the given sequence are 0, 2, 14, 15.
The 3rd missing number is 14.

**Example 2:**

**Input :** Arr[] = {1, 2, 3, 4, 5}
Brr[] = {5, 4, 3, 1, 2} and K = 3
**Output :** -1

**Your Task:**

This is a function problem. The input is already taken care of by the driver code. You only need to complete the function **MissingNumber()** that takes an array **(a)**, another array **(b)**, an element **K,** size of first array **(n)**, size of the second array **(m)****, **and return the Kth missing number in an array **a, **if you can't find it return **-1**. The driver code takes care of the printing.

**Expected Time Complexity:** O(n + m).

**Expected Auxiliary Space:** O(m).

**Constraints:**

1 ≤ n,m,k ≤ 10^{5}

1 ≤ a[i] ≤ 10^{8}

1 ≤ b[i] ≤ 10^{3}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Find k-th missing element

...