This file contains hidden or 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.scottshipp.code; | |
| import java.util.HashMap; | |
| import java.util.Map; | |
| public class AnagramChecker { | |
| public boolean isAnagram(String firstWord, String secondWord) { | |
| if(firstWord == null || secondWord == null || firstWord.length() != secondWord.length()) { | |
| return false; |
This file contains hidden or 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
| /** | |
| * Definition for a binary tree node. | |
| * public class TreeNode { | |
| * int val; | |
| * TreeNode left; | |
| * TreeNode right; | |
| * TreeNode(int x) { val = x; } | |
| * } | |
| */ | |
| class Solution { |
This file contains hidden or 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 FindMinComparing { | |
| public int findMin(int[] arr) { | |
| if(arr == null) { | |
| throw new IllegalArgumentException("Received null array"); | |
| } | |
| if(arr.length < 1) { | |
| throw new IllegalArgumentException("Received zero-length array"); | |
| } | |
| if(arr.length == 1) { |
This file contains hidden or 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
| # from https://codeburst.io/how-i-hacked-my-terminal-so-a-happy-whale-would-spout-software-quotes-at-me-6791e6c74fc6 | |
| % | |
| Simple things should be simple, complex things should be possible. | |
| The Wiki Way: Quick Collaboration on the Web, Bo Leuf, Ward | |
| Cunningham | |
| % | |
| Simplicity is the soul of efficiency. | |
| Austin Freeman | |
| % |
This file contains hidden or 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
| % | |
| Simple things should be simple, complex things should be possible. | |
| The Wiki Way: Quick Collaboration on the Web, Bo Leuf, Ward | |
| Cunningham | |
| % | |
| Simplicity is the soul of efficiency. | |
| Austin Freeman | |
| % | |
| I have yet to see any problem, however complicated, which, when you | |
| looked at it in the right way, did not become still more complicated. |
This file contains hidden or 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
| find . -type f -exec sed -i -e 's/world/universe/g' {} \; |
This file contains hidden or 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
| awk 'FNR==1{print "%"}{print}' quote* > softwareengineering |
This file contains hidden or 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.Scanner; | |
| public class PermutationGenerator1 { | |
| private static String inputWithoutC(String input, char c) { | |
| String inputWithoutC = ""; | |
| char[] temp = input.toCharArray(); | |
| for(char d : temp) { | |
| if(d !=c ) { | |
| inputWithoutC += d; |
This file contains hidden or 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
| implicit class NullSafeOption[A,B](val a: Option[A]) extends AnyVal { | |
| def mapNullSafe(f: A => B): Option[B] = { a.flatMap(x => Option(x).map(f)) } | |
| } | |
| implicit class NullSafe[A,B](val a: A) extends AnyVal { | |
| def ?(f: A => B): B = { if(a == null) null.asInstanceOf[B] else f(a) } | |
| } | |
| //Examples with Option + Map | |
| scala> val s: String = null |
This file contains hidden or 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
| // from https://code.scottshipp.com/2016/07/28/does-scala-have-the-safe-navigation-null-conditional-operator/ | |
| implicit class NullSafe[A, B](val a: A) extends AnyVal { | |
| def ?(f: A => B): B = { if(a == null) null.asInstanceOf[B] else f(a) } | |
| } | |
| //example | |
| val s = "Hello, World!" | |
| s?(_.reverse)?(_.reverse) //returns "Hello, World!" | |
| val sNull: String = null |