From 107867971febcd1517de1ec07be294c9e35cc952 Mon Sep 17 00:00:00 2001 From: amitkrjha-geek <70425790+amitkrjha-geek@users.noreply.github.com> Date: Mon, 4 Oct 2021 15:42:02 +0530 Subject: [PATCH] Create Set Mismatch --- Sets/Set Mismatch | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Sets/Set Mismatch diff --git a/Sets/Set Mismatch b/Sets/Set Mismatch new file mode 100644 index 0000000..38f84d0 --- /dev/null +++ b/Sets/Set Mismatch @@ -0,0 +1,12 @@ +The idea is using array indexing, that is putting each nums[i] into the position with index nums[i] - 1. Then, the array becomes [1,2,3,4,5...,n]. So we can find the duplicate number when nums[i] != i+1. + +``` +vector findErrorNums(vector& nums) { + for(int i = 0; i