+ 1
What am I doing wrong in this simple code ? Why am I always getting the output as "false" ?
Problem:- Given a list of numbers and a number k, return whether any two numbers from the list add up to k. For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17. Here's my code :- https://code.sololearn.com/cb4g92XJ9k5d/?ref=app
2 Respuestas
+ 4
you assign k to local variable, not to k as class field
//int k = sc.nextInt();
k = sc.nextInt();
+ 2
zemiak o yeah true...🤦🏻♀️
and thanks for helping 👍