12345678910111213141516171819 |
- /* This is a reverse coding challenge.
- * Normally you're given explicit directions with how to create a function.
- * Here, you must generate your own function to satisfy the relationship
- * between the inputs and outputs.
-
- * Your task is to create a function that, when fed the inputs below,
- * produce the sample outputs shown.
- */
- std::vector<int> mysteryFunc(std::vector<int> arr, int num) {
- std::vector<int> remaindarray;
- // THE SECRET: its an array output of the remainders from input array.
- // loop through the array
- for(int i=0;i<arr.size();i++){
- // check divisibility of each element. then store remainder into new array.
- remaindarray.push_back(arr[i]%num);
- }
- return remaindarray;
- }
|