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 / localization.json
Created April 17, 2024 15:39
jojo localization
{
"Become conversational": "",
"talk like a native in any language": "",
"Real conversations": "",
"Grammar explanations": "",
"Translation breakdowns": "",
"change your foreign language": "",
"help": "",
"Login": "",
"Register": "",
@kylelong
kylelong / capitalAfterVowel.js
Created December 19, 2022 09:55
capitalAfterVowel.js - cassidoo 12/19/2022
const capitalAfterVowel = (phrase) => {
if (phrase.length === 0) return;
let indices = [];
for (let i = 1; i < phrase.length; i++) {
if (/^[aeiou]$/.test(phrase[i - 1]) && !/^[aeiou]$/.test(phrase[i])) {
indices.push(i);
}
}
let copy = [];
phrase.split("").map((elem, index) => {
const numberOfOnes = (num) => {
let sum = 0;
for(let i = 0; i <= num; i++){
sum += i.toString().split("").filter(number => number === '1').length;
}
return sum;
}
console.log(numberOfOnes(14)); //7
package com.company;
import java.util.*;
public class Trie {
public static void main(String[] args) {
// String s = "tttt";
Trie t = new Trie();
// t.insert(s);
// t.insert("ttt");
// System.out.println(t.startsWith("tt"));
class Trie {
public static void main(String[] args) {
String s = "tttt";
Trie t = new Trie();
t.insert(s);
t.insert("ttt");
System.out.println(t.startsWith("tt"));
}
@kylelong
kylelong / oneRow.js
Created May 9, 2020 05:56
5/3/2020 interview problem of the week - oneRow
//Week of May 3rd 2020
//Given an array of words, return the words that can be typed using letters of only one row on a keyboard.
//QWERTY keyboard only
let rowOne = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p']
let rowTwo = ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l']
let rowThree = ['z', 'x', 'c', 'v', 'b', 'n', 'm']
//Looks at eache character of each word and dtermines if they are on the same row (in the same array as the first letter )
function oneRow (arr) {
words = []
for (let i = 0; i < arr.length; i++) {
@kylelong
kylelong / BTLOT.java
Created October 31, 2019 16:51
Binary Tree Level Order Traversal
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
class BTLOT {
@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 {
@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 / 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]