Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# 99Tech Code Challenge #1 #

Note that if you fork this repository, your responses may be publicly linked to this repo.
Please submit your application along with the solutions attached or linked.

It is important that you minimally attempt the problems, even if you do not arrive at a working solution.

## Submission ##
You can either provide a link to an online repository, attach the solution in your application, or whichever method you prefer.
We're cool as long as we can view your solution without any pain.
# 99Tech Code Challenge #1 #
Note that if you fork this repository, your responses may be publicly linked to this repo.
Please submit your application along with the solutions attached or linked.
It is important that you minimally attempt the problems, even if you do not arrive at a working solution.
## Submission ##
You can either provide a link to an online repository, attach the solution in your application, or whichever method you prefer.
We're cool as long as we can view your solution without any pain.
9 changes: 9 additions & 0 deletions src/problem1/.hintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": [
"development"
],
"hints": {
"typescript-config/consistent-casing": "off",
"typescript-config/strict": "off"
}
}
31 changes: 31 additions & 0 deletions src/problem1/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Problem 4: Three ways to sum to n
// Recursive implementation
// Time Complexity: O(n), Space Complexity: O(n) due to recursion stack
function sum_to_n_a(n: number): number {
if (n <= 0) return 0;
if (n === 1) return 1;
return n + sum_to_n_a(n - 1);
}

// Iterative implementation
// Time Complexity: O(n), Space Complexity: O(1)
function sum_to_n_b(n: number): number {
let sum = 0;
for (let i = 1; i <= n; i++) {
sum += i;
}
return sum;
}

// Formula-based implementation
// Time Complexity: O(1), Space Complexity: O(1)
function sum_to_n_c(n: number): number {
return n > 0 ? (n * (n + 1)) / 2 : 0;
}

console.log(sum_to_n_a(5)); // 15
console.log(sum_to_n_b(10)); // 55
console.log(sum_to_n_c(0)); // 0
console.log(sum_to_n_a(-3)); // 0
console.log(sum_to_n_b(1)); // 1
console.log(sum_to_n_c(100)); // 5050
213 changes: 213 additions & 0 deletions src/problem1/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/problem1/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"ts-node": "^10.9.2",
"typescript": "^5.8.3"
}
}
8 changes: 8 additions & 0 deletions src/problem1/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"module": "CommonJS",
"target": "ES2020",
"outDir": "dist"
},
"include": ["index.ts"]
}
Loading