This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ListNode | |
attr_accessor :val, :next | |
def initialize(val) | |
@val = val | |
@next = nil | |
end | |
end | |
@carry = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####################### | |
# Version 1 - O(n^2) | |
####################### | |
def max_seq(chars, x = 0, y = 0) | |
return chars if chars.size < 2 | |
combinations = {} | |
(0...chars.size).each do |x| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COINS = [1,3,6,10,15,20,30,50] | |
@cache = [] | |
def min_change(amount) | |
return 0 if amount == 0 | |
min = 9999999999 | |
possible_coins = COINS.select { |n| n <= amount } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALPHABET_SIZE = 26 | |
def caesar_cipher(string) | |
shiftyArray = [] | |
charLine = string.chars.map(&:ord) | |
shift = 1 | |
ALPHABET_SIZE.times do |shift| | |
shiftyArray << charLine.map do |c| | |
((c + shift) < 123 ? (c + shift) : (c + shift) - 26).chr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "array.h" | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <errno.h> | |
struct ArrayData *initArray() { | |
struct ArrayData *newArray = malloc(sizeof(struct ArrayData)); | |
newArray->pointer = calloc(1000, sizeof(int)); | |
newArray->size = 1000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<pre> | |
<?php | |
// Creating an array | |
$chars = array(); | |
array_push($chars,'a','b','c'); |
NewerOlder