TORONTO KIDS COMPUTER CLUB | Aurora Thursday Java 18:00 – 04.29
19336
post-template-default,single,single-post,postid-19336,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.8.0,vc_responsive

Aurora Thursday Java 18:00 – 04.29

26 Apr Aurora Thursday Java 18:00 – 04.29

Question 1:
Given an array of number represented by arr and a target sum (n), check if two numbers exists in the array whose sum is equal to the target sum

Sample Test 1:
Input
arr = [3, 5, -4, 8, 11, 1, -1, 6]
targetsum = 10

Output:
true

Explanation:
The sum of 11 and -1 is 10, which is equal to the targetsum (10), which is why the output is true


Sample Test 2:
Input
arr = [4, 6, 1, -3]
targetsum = 3

Output:
false

Explanation: 
In the arr, there are no two numbers whose sum is equal to 3 which is why the output is false

Question 2:
Given an array of numbers, print true if all the numbers in the array are indentical otherwise print false.

Note: you can solve this question without a hashset but please try to solve this question using hashset.

Sample Test 1:
Input
arr = [2,2,2,2,2]

Output
true

Explanation: 
All the numbers in the array are identical (all are 2s), due to which the output is true

Sample Test 2
Input
arr = [9,1,9,9]

Output
false

Explanation: 
All the numbers in the array are not identical, due to which the output is false
No Comments

Sorry, the comment form is closed at this time.