# Code, Archeology, and Line Breaks

## Did you know \r and \n are remnants of typewriters?

`HelloWorld!`

# Daily Coding Problem Write-up

## `O(n) runtime, O(n) space`

`vector<int> productExceptSelf(vector<int>& nums) {    int n = nums.size();    // Initialize vectors (i.e. arrays) of n 1’s    vector<int> result(n, 1);    vector<int> fromBegin(n, 1);    vector<int> fromEnd(n, 1);    for(int i=1; i<n; i++){        fromBegin[i] = fromBegin[i-1] * nums[i-1];        fromEnd[i] = fromEnd[i-1] * nums[n-i];    }    for(int i=0; i<n; i++){        result[i] = fromBegin[i] * fromEnd[n-1-i];    }    return result;}`
• `fromBegin = [1…`

# Daily Coding Problem Write-up

## Day 1 — Two Sum

`nums = [2, 7, 11, 15]target = 9return [0, 1]`

## Bruteforce — O(n²) runtime, O(1) space

`vector<int> twoSum(vector<int>& nums, int target) {    vector<int> result;    for(int j=1; j < nums.size(); j++){        for(int i=0; i < j; i++){            if(nums[i] + nums[j] == target){                result.push_back(i);                result.push_back(j);                return result;            }        }    }    return result; // no results found, return empty vector}`

## Hash Table — O(n) runtime, O(n) space

`vector<int> twoSum(vector<int>& nums, int target) {    // maps remainder (target - current_val) to vector index (i)    // e.g. …`

## Donovan So

Get the Medium app