Google-Developer-Student-Club-CCOEW / Competitive-Programming-2023-GDSC-CUMMINS-X-GDSC-MMCOE

Welcome to the Hacktoberfest 2023 Competitive-Programming Cohort for Cummins College and MMCOE students! To request issue assignment, create a pull request, providing: 1. Full Name πŸ§‘β€πŸŽ“ 2.Email πŸ“§ 3.College ID (RNO) πŸ”’ 4.Branch of Study.πŸ“š 5. Year πŸ“† .The Cummins College and MMCOE students' PRs will be considered only. Thank you!
9 stars 69 forks source link

Merge Two 2D Arrays by Summing Values #74

Closed saakshii12 closed 11 months ago

saakshii12 commented 1 year ago

Write code in the preferred language and attach output with it.

You are given two 2D integer arrays nums1 and nums2.

nums1[i] = [idi, vali] indicate that the number with the id idi has a value equal to vali. nums2[i] = [idi, vali] indicate that the number with the id idi has a value equal to vali. Each array contains unique ids and is sorted in ascending order by id.

Merge the two arrays into one array that is sorted in ascending order by id, respecting the following conditions:

Only ids that appear in at least one of the two arrays should be included in the resulting array. Each id should be included only once and its value should be the sum of the values of this id in the two arrays. If the id does not exist in one of the two arrays then its value in that array is considered to be 0. Return the resulting array. The returned array must be sorted in ascending order by id.

Example 1:

Input: nums1 = [[1,2],[2,3],[4,5]], nums2 = [[1,4],[3,2],[4,1]] Output: [[1,6],[2,3],[3,2],[4,6]] Explanation: The resulting array contains the following:

Input: nums1 = [[2,4],[3,6],[5,5]], nums2 = [[1,3],[4,3]] Output: [[1,3],[2,4],[3,6],[4,3],[5,5]] Explanation: There are no common ids, so we just include each id with its value in the resulting list.

anu-shka-k commented 12 months ago

Hi @saakshii12, could you please assign this issue to me?

51tejalhajari commented 11 months ago

Can u please assign this issue to me ? Name -> Tejal Hajari SY EnTC E-mail -> tejal.hajari@cumminscollege.in