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

 

test2024_10_31_HL_missingNum


For this method, 'nums' will contain an unsorted array of positive integers, starting with 1. All consecutive integers from 1 up to the maximum value in the array will be included EXCEPT for ONE value. Your goal is to find the missing number without causing a timeout error. You may assume that the maximum number in the array will NOT be missing, although the value of 1 could be missing, as well as any other value up to but not including the maximum number. NOTE: There will only be ONE missing number! For this problem you are NOT allowed to use maps, functional programming, or Strings. Efficiency will be important in order to avoid time-out errors.


test2024_10_31_HL_missingNum([53, 26, 21, 40, 22, 43, 51, 25, 32, 14, 46, 7, 45, 47, 41, 15, 11, 42, 16, 27, 35, 23, 20, 31, 39, 4, 5, 10, 13, 30, 3, 12, 62, 57, 8, 29, 38, 34, 1, 37, 19, 56, 48, 24, 44, 18, 17, 28, 54, 61, 60, 6, 50, 36, 55, 59, 2, 33, 9, 49, 58]) → 52
test2024_10_31_HL_missingNum([53, 26, 21, 40, 22, 43, 51, 25, 32, 14, 46, 7, 45, 47, 41, 15, 11, 42, 16, 27, 35, 23, 20, 31, 39, 4, 5, 10, 13, 30, 3, 12, 62, 57, 8, 29, 38, 34, 1, 37, 19, 56, 48, 24, 44, 18, 17, 28, 54, 61, 60, 6, 50, 36, 55, 59, 2, 33, 9, 49, 52]) → 58
test2024_10_31_HL_missingNum([5, 6, 3, 4, 1, 2, 9, 8]) → 7

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

public int test2024_10_31_HL_missingNum(int[] 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: 290

Copyright Nick Parlante 2017 - privacy