Skip to content

Instantly share code, notes, and snippets.

@sajadtorkamani
Created February 6, 2020 16:20
Show Gist options
  • Save sajadtorkamani/a8b32328387fc4c547c5cf1223f19f50 to your computer and use it in GitHub Desktop.
Save sajadtorkamani/a8b32328387fc4c547c5cf1223f19f50 to your computer and use it in GitHub Desktop.
Find min example
// The counter implementation to the weird function!
const solution = n => {
let result = [];
for (let num = 1; num <= n; num++) {
result.push(num);
}
return result;
};
// The weird function
function find_min(A) {
var ans = 0;
for (var i = 1; i < A.length; i++) {
if (ans > A[i]) {
ans = A[i];
}
}
return ans;
}
console.log(solution(6));
console.log(find_min(solution(6)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment