Skip to content

Instantly share code, notes, and snippets.

@4RSIM3R
Last active September 12, 2023 00:22
Show Gist options
  • Save 4RSIM3R/f1be530e161c7218732ba61ca793cd90 to your computer and use it in GitHub Desktop.
Save 4RSIM3R/f1be530e161c7218732ba61ca793cd90 to your computer and use it in GitHub Desktop.
[Easy] Soal Nomer 1
// Complete this function, that determine is given number can be
// square rooted or not
// example :
// payload : 4
// the result is true, because 4 is 2 to the power of 2
// Complete this function, that will add up two item of a 'payload'
// that equal to 'target'
// example :
// target = 9
// payload = [2, 7, 5, 1]
// so to have 9, you can add 2 in index 0 and 7 in index 1
// so return a list of int that will store the index value of desired item
List<int> composeTwoSum(int target, List<int> payload) {
return [];
}
main() {
var test1 = composeTwoSum(9, [2, 7, 5, 1]); // [0, 1]
var test2 = composeTwoSum(1, [2, 3, 4, 5]); // []
var test3 = composeTwoSum(10, [2, 7, 5, 8]); // [0, 3]
print(test1);
print(test2);
print(test3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment