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 ReverseInteger { | |
public static int reverseInteger(int num){ | |
long reversedNum = 0L; | |
while(num != 0){ | |
//Calculate the remainder | |
reversedNum = (num % 10) + (reversedNum * 10); | |
//Recalculate num to remove digit from tens place | |
num = num / 10; | |
if (doesOverflow(reversedNum) || doesUnderflow(reversedNum)) { |
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
import java.io.*; | |
import java.util.ArrayList; | |
import java.util.stream.Stream; | |
class Car implements Serializable { | |
private String make; | |
private String model; | |
public Car(String make, String model) { | |
this.make = make; |
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
func fibonacci(n: Int) -> Int { | |
var numbers = [Int:Int]() | |
return fibHelper(n: n, nums: &numbers) | |
} | |
func fibHelper(n: Int, nums: inout [Int:Int]) -> Int { | |
if let result = nums[n] { | |
return result; | |
} else if n == 1 { |
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
package com.company; | |
import java.util.Scanner; | |
//Uncomment the class definition. | |
/** | |
class Checkbox { | |
private boolean isChecked = 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
public class Heap { | |
private static int ROOT = 1; | |
private static int DEFAULT_SIZE = 3; | |
Integer[] elements; | |
int numberOfElements; | |
public Heap() { | |
this.numberOfElements = 0; |
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
def is_valid(string): | |
if (len(string)) % 2 != 0: | |
return False | |
braces = {'[':']', '{': '}', '(': ')'} | |
opening_braces = braces.keys() | |
stack = [] | |
for char in string: | |
if char in opening_braces: | |
stack.append(char) |
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
import os, sys | |
JAVA_TEMPLATE = """ | |
public class Main { | |
public static void main(String[] args) { | |
System.out.println("Hello world!"); | |
} | |
} | |
""" |
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
import java.util.ArrayList; | |
import java.util.stream.Collectors; | |
class Node<K extends Comparable<K>, V> { | |
K key; | |
V value; | |
Node<K, V> parent; | |
Node<K, V> left; | |
Node<K, V> right; |
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
//___FILEHEADER___ | |
import Foundation | |
// To use this as a template, do the following: | |
// 1. Create the 'Custom' directory -> mkdir -p ~/Library/Developer/Xcode/Templates/File\ Templates/Custom | |
// 2. Open Finder, CMD + G into this directory /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates | |
// 3. Open 'Source' directory and copy the Swift File.xctemplate | |
// 4. Paste the Swift File.xctemplate into to the 'Custom' directory from step 1 | |
// 5. Rename the Swift File.xctemplate in the 'Custom' directory to the desired name for the template |
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
// | |
// Alert.swift | |
// DoTryCatch | |
// | |
// Created by Sean Allen on 8/30/17. (Big ups to Sean Allen) | |
// Copyright © 2017 Sean Allen. All rights reserved. | |
// | |
import Foundation | |
import UIKit |
OlderNewer