id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

tmhscs@gmail.com sets > setMismatch
prev  |  next  |  chance

The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to another number in the set, which results in repetition of one number and loss of another number. Given an array list nums representing the data status of this set after the error. Your task is to firstly find the number occurs twice and then find the number that is missing. Return them in the form of an array.


setMismatch([1, 2, 2, 4]) → [2, 3]
setMismatch([3, 5, 7, 2, 7, 1, 6, 4, 8, 10]) → [7, 9]
setMismatch([3, 2, 6, 3, 5, 4]) → [3, 1]

...Save, Compile, Run (ctrl-enter)

public int[] setMismatch(ArrayList<Integer> nums) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 200

Copyright Nick Parlante 2017 - privacy