Skip to content

Commit 503ef43

Browse files
committed
add problem
1 parent c5e1b6d commit 503ef43

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ to potential employers. Score well on one of our public tests, and you will get
189189

190190
- :octocat: **MaximAbramchuck/awesome-interview-questions** - https://github.com/MaximAbramchuck/awesome-interview-questions - A curated awesome list of lists of interview questions.
191191

192-
## Technical blogs
192+
## Technical blogs 💸
193193

194194
This is tangentially related to interviews. Below is a list of companies that feature blog posts from guest authors. Blogging and teaching others can be a powerful way to comprehend new material, fine tune your writing skills, gain exposure and potentially even make money! If you have a technical blog open to new contributors please [submit a PR](https://github.com/connor11528/coding-interviews/pulls)
195195

practice/exercises.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,25 @@ function findMissingLetter(array){
344344
}
345345
}
346346

347+
348+
// Sort a sorted array by their squares
349+
// [1,2,3] => [1, 4, 9]
350+
// [-10, -1, 0, 1, 2] => [0, 1, 1, 4, 100]
351+
352+
function sortNums(arr){
353+
var start = 0, end = arr.length - 1, output = [];
354+
355+
while (start <= end) {
356+
if (Math.abs(arr[start]) > Math.abs(arr[end]))
357+
{
358+
output.unshift(Math.pow(arr[start], 2))
359+
start++;
360+
} else {
361+
output.unshift(Math.pow(arr[end], 2))
362+
end--;
363+
}
364+
}
365+
366+
return output;
367+
}
368+

0 commit comments

Comments
 (0)