Little problem(s) July 2022
|
07-04-2022, 06:04 PM
(This post was last modified: 07-07-2022 05:31 PM by pier4r.)
Post: #1
|
|||
|
|||
Little problem(s) July 2022
#1 Sum of two integers in a list
Input: L2: a list (or an array) of positive integers values L1: an integer Int1 Output: L1: the positions of the two different (!) elements in the list in input whose sum is equal to Int1 Constraints: - Assume the input list to have only one couple of values that equals to Int1 or none. No duplicates. #2 Sum of two integers in a list bonus No1 Like the problem in #1 but try to get less than O(n^2) #3 Sum of integers in a list bonus No2 Input: L2: a list (or an array) of positive integers values L1: an integer Int1 Output: L1: the positions of the different (!) elements in the list in input whose sum is equal to Int1, so that the number of elements that produce the sum is maximum (if it is possible to equal Int1). If multiple options are possible, one is to be picked. Example inputs: { 1 2 3 2 2 1 } 6 output: { 1 2 4 6 } @1 2 2 1 @alternative { 1 2 5 6 } Wikis are great, Contribute :) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 6 Guest(s)