Skip to content

Instantly share code, notes, and snippets.

View kylelong's full-sized avatar
🌴
On vacation

Kyle Long kylelong

🌴
On vacation
View GitHub Profile
@kylelong
kylelong / removeOdd.java
Created February 24, 2019 06:43
Week of 2/17/19 Cassido's interview question of the week
/**
* Created by Kyle Long on 2/24/19.
*/
public class removeOdd {
public static void main(String [] args){
System.out.println(removeForOdd(new int[]{2,4,6,7,8}));
System.out.println(removeForOdd(new int[]{4,4,4}));
System.out.println(removeForOdd(new int[]{1,2,3,4,5,6,7}));
}
@kylelong
kylelong / phonePad.java
Created March 3, 2019 03:34
Cassido's weekly newsletter interview question of the week 2/24/19
import java.util.*;
/**
* Created by kylel95 on 3/1/19.
*/
public class phonePad {
public static void main(String [] args){
String s = "123456";
perm1(makeString(s));
}
@kylelong
kylelong / squarecubed.js
Last active March 21, 2019 17:28
Cassido's newsletter interview question of the week 3/18
let nums = []
function squareCubeNums(num){
for(var i = 1; i <= num; i++){nums[i] = i;}
//Check for perfect square && check for perfect cube
nums = nums.filter(number => Math.floor(Math.sqrt(number)) - Math.sqrt(number) == 0 && Math.pow(Math.round(Math.pow(number, 1/3)), 3) == number);
console.log(nums);
}
squareCubeNums(64);
@kylelong
kylelong / trailing.rb
Created March 29, 2019 22:34
Cassido's interview question of the week (3/24/19)
#Given an integer N, find the number of trailing zeroes
# in the base 16 representation of the factorial of N.
def trailing(number)
num = factorial(number).to_s(16)
length = num.length
chars = num.split('')
count = 0
for c in num.split('').reverse()
if(c == '0')
count += 1
@kylelong
kylelong / lastUnique.java
Last active May 22, 2019 03:56
Cassido's interview question of the week 5/19/19 - Find the last non-repeating character in a given string.
import java.util.HashMap;
/**
* Created by kylel95 on 5/21/19.
* Find the last non-repeating character in a given string.
*/
public class lastUnique {
public static void main(String [] args){
String s = "candy canes do taste yummy";
@kylelong
kylelong / division.rb
Created June 3, 2019 05:04
Cassido's interview question for week of 5/26/19 - Implement integer division
=begin
Integer dvision for a / b
@param a first number
@param b second number
@return a / b
=end
def divide(a, b)
sign = (a < 0) ^ (b < 0) ? -1 : 1
a = a.abs
b = b.abs
@kylelong
kylelong / maxRange.rb
Last active June 9, 2019 05:01
6/2/19 Cassido's interview question of the week
#Given an array of integers, find the maximum range between two elements in the array.
def maxRange(arr)
return arr.max.abs - arr.min.abs
end
puts maxRange([2,2,1,3]) #2
puts maxRange([0]) #0
puts maxRange([4,3,5,7,1,7,7,6]) #6
@kylelong
kylelong / hexToRgb.rb
Created June 17, 2019 06:29
6/9/19 Cassido's weekly interview problem - Convert Hex to RGB
=begin
Converts hex codes to rgb
https://www.mathsisfun.com/hexadecimals.html
supports hashtag and non hashtag
@param s string to be converted to RGB
@return RGB representation of a string
=end
def hex_to_rgb(s)
if s[0] == "#" #removes '#' from evalutation
s = s[1..s.length]
@kylelong
kylelong / Growth.java
Created September 28, 2019 22:22
See growth rates of n for a few functions
public class Growth{
/**
n!,2n,2​n^2, 5nlogn,20n,10n
*/
public static void main(String [] args){
long fact, twon, twon2, fivenlogn, twentyn, tenn;
for(long i = 0; i < 20; i++){
fact = fact(i);
twon = (long)Math.pow(2, i);
twon2 = 2 * (long)Math.pow(i, 2);
@kylelong
kylelong / BinaryParser.java
Created October 17, 2019 02:17
BinaryParser
import java.io.*;
import java.nio.ByteBuffer;
public class BinaryParser {
/**
* byte array Byte buffer
* @param args
*/
public static void main(String[] args) {
try {