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 AutocompleteSystem { | |
TrieNode root; | |
TrieNode rootCopy; | |
StringBuilder currSentence; | |
Map<String, Sentence> sentenceRefs; | |
/** | |
* Requirements: | |
* - Users may input a sentence (each sentence must contain at least one word and end with "#") |
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 Solution { | |
public boolean detectCapitalUse(String word) { | |
if(allCapital(word)){ | |
return true; | |
} | |
if(noneCapital(word)){ | |
return true; | |
} |
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 EvaluateDivision { | |
public double[] calcEquation(List<List<String>> equations, double[] values, List<List<String>> queries) { | |
/** | |
1. Traverse Edge List & Create Ajacency List (Use Map<String, List of Adjs>) | |
2. Remember going from point A to point B carries a weight, so we need to include that in our adjacent list. So instead of storing just a list of adjacent strings, we can store a list of adjacent Node (class) that will contain the string and weight as fields | |
3. Remember if A / B = 2.0, then B / A = 1/2.0. So when building the adjacency list, be sure to treat paths as bidirectional, but with weight differences (see first sentence). | |
4. For each query, try to go from start node to destination node. If possible, get total value, if not possible, answer for that query is -1.0 | |
5. To ensure nodes aren't visited twice for each query, use a set |
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 Solution { | |
public boolean isPalindrome(String s) { | |
if(s.isEmpty()){ | |
return true; | |
} | |
s = s.toLowerCase(); | |
int start = 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
import requests | |
queue = [] | |
queue.append('https://findtreasure.app/api/v1/games/ileya/e99f8a41-e151-4e81-bf5e-cf2a92229177') | |
headerx={ | |
'Content-Type' : 'application/json', | |
'Authorization' : 'Bearer token-here', | |
'gomoney' : 'phone-number-here' | |
} |
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
/**Big Sorting*/ | |
public class Solution{ | |
static String[] bigSorting2(String[] unsorted) { | |
Arrays.sort(unsorted, new Comparator<String>() { | |
public int compare(String n1, String n2) { | |
if (n1.length() != n2.length()) { | |
return n1.length() - n2.length(); //Still obeys compares -1 0 1 | |
} | |
return n1.compareTo(n2); | |
} |
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
BeanUtils.copyProperties(data, entity, getNullPropertyNames(data)); | |
/** | |
* Ensures that null fields from source are omitted | |
*/ | |
public static String[] getNullPropertyNames(Object source) { | |
final BeanWrapper src = new BeanWrapperImpl(source); | |
java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors(); | |
Set<String> emptyNames = new HashSet<>(); | |
for (java.beans.PropertyDescriptor pd : pds) { | |
//check if value of this property is null then add it to the collection |
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
MIGRATION_LABEL = "change_log_" | |
# Use NUMBER to seperate change log files and also to make file naming easy | |
VERSION = "2" | |
# mvn liquibase:generateChangeLog --changeLogFile=src/main/resources/db/changelogs/change_log_1.yml | |
makeMigration: | |
mvn liquibase:diff -DdiffChangeLogFile=src/main/resources/db/changelog/${MIGRATION_LABEL}_${VERSION}.yml | |
@echo " - include:" >> classpath:db/db.changelog-master.yml | |
@echo " file: /src/main/resources/db/changelog/$(VERSION)-$(MIGRATION_LABEL).yml" >> classpath:db/db.changelog-master.yml |
NewerOlder