Skip to content

Instantly share code, notes, and snippets.

View primaryobjects's full-sized avatar

Kory Becker primaryobjects

View GitHub Profile
@primaryobjects
primaryobjects / index.html
Last active June 26, 2021 21:38
React example in browser using useState, useEffect, ReactJs from a web page. https://jsbin.com/yudorurupi/edit?html,js,output
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Authors</title>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<script crossorigin src="https://unpkg.com/react@17/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser-polyfill.min.js'></script>
// 1,2,3,5,4,6,7,8 => 1
// 4,1,2,3 => Too chaotic
class Result
{
public static void minimumBribes(List<int> q)
{
bool isChaotic = false;
int bribes = 0;
for (int i=0; i<q.Count; i++)
// 1,2,3,4,5 d=4
// 5,1,2,3,4
public static List<int> rotLeft(List<int> a, int d)
{
if (a != null && a.Count > 1)
{
List<int> b = new List<int>();
// d = 3
// 1,2,3,4,5
@primaryobjects
primaryobjects / largestInt.js
Last active June 11, 2021 18:55
Largest integer that can be formed by rearranging digits, without using string methods. https://jsitor.com/9TKcPTMN9
const largestInt = n => {
const digits = [];
// Extract digits.
while (n) {
const digit = n % 10;
digits.push(digit);
n = Math.floor(n / 10);
}
@primaryobjects
primaryobjects / MergeSorted.java
Last active June 11, 2021 03:09
Merge two sorted lists into a single sorted list, MergeSorted using a linked list algorithm.
/* Given two sorted lists, merge the lists together into sorted order.
Example: [1,3,20] and [2,5,10,15] => [1,2,3,5,10,15,20]
https://jdoodle.com/ia/ez4
*/
public class MergeSorted
{
private Node head, tail;
public MergeSorted()
{
@primaryobjects
primaryobjects / employee.ts
Created April 30, 2021 02:05
Hello World in TypeScript using Employee example. https://jsitor.com/o3wJRyw3f
enum DepartmentType {
Engineering,
Data,
HR,
CustomerService
}
class IdGenerator {
static _id: number = 0;
@primaryobjects
primaryobjects / twoSumDp.js
Last active January 29, 2022 04:25
Find the two indices in an array of numbers that add sum to a target value. https://leetcode.com/problems/two-sum/submissions/
// Using dynamic programming.
var twoSumDp = function (nums, target, i, n, indices) {
n = n === undefined ? 0 : n;
i = i === undefined ? nums.length - 1 : i;
indices = indices === undefined ? [] : indices;
if (i < 0) {
// We ran out of values.
return { n, indices };
}
@primaryobjects
primaryobjects / quiz6.txt
Last active March 28, 2024 10:56
Finance for Non-Finance Professionals Week 5 Final Exam
1.
Question 1
In 5 years you are going to get $2,000.
If interest rates unexpectedly rise, the present value of that future amount to
you would
1 point
### Fall
@primaryobjects
primaryobjects / quiz5.txt
Created April 3, 2021 02:50
Finance for Non-Finance Professionals - Week 4 Quiz 2
1.
Question 1
Stock A has a beta of 0.8, whereas stock B has a beta of 1.5. Which one of these stocks would you recommend to a very risk-averse investor?
1 point
### Stock A
Stock B
@primaryobjects
primaryobjects / quiz4.txt
Created April 3, 2021 02:46
Finance for Non-Finance Professionals - Week 4 Quiz 1
What happens to a firm’s WACC if the firm’s tax rate increases?
1 / 1 point
WACC increases
### WACC decreases