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
/** | |
* Write a function called longestSubstring, which accepts a string and returns the | |
* length of the longest substring with all distinct characters. | |
* | |
* O(N) | |
* | |
*/ | |
function longestSubstring(str) { | |
let longest = 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
/** | |
* Implement a function called hasDuplicates which accepts | |
* a variable number of integer arguments and returns | |
* true if there are duplicates in the arguments. | |
* | |
* Should be solved in O(n) or better. | |
* | |
*/ | |
function hasDuplicates(...args) { |
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
/** | |
* Implement a function called hasDuplicates which accepts | |
* a variable number of integer arguments and returns | |
* true if there are duplicates in the arguments. | |
* | |
* Should be solved in O(n) or better. | |
* | |
*/ | |
function hasDuplicates(...args) { |
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
/** | |
* 🔥🔥🔥🔥 Sliding Window Pattern 🔥🔥🔥🔥 | |
* | |
* - Easy to implement | |
* - Can be tricky to reason about | |
* - Good at making O(n^2) Subset / Subarray problems O(n) | |
* | |
* ----- | |
* | sum | | |
* ----- |
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
/** | |
* | |
* Two Pointers Technique: | |
* - Simple to implement | |
* - Typically improves time complexity from O(n^2) to O(n). | |
* - Often used for searching for pairs in a sorted array | |
* | |
* Write a fx named uniqueValues that accepts a sorted array, and | |
* returns an integer representing the number of unique values in the array. | |
* The array may contain negative values. |
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
/** | |
* Multiple Pointer Pattern Challenge 👻 closing in on the middle 👻 | |
* | |
* see live at https://dartpad.dartlang.org/1df653a9a71a17e78e58397c040033ca | |
* | |
* Write a fx called sumZero which accepts a sorted array of integers. | |
* The fx should find the first pair where the sum is 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
// Callable classes in Dart (as of v2.5) | |
// See live at https://dartpad.dartlang.org/ab72121a4c0fe4d1a3c29697d9a108dd | |
void main() { | |
MyCallableClass()(); | |
} | |
class MyCallableClass { | |
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
// Basic Data Structures in Dart (as of v2.5) | |
// See live at https://dartpad.dartlang.org/a4dd3a27e5750a029de689391ae90004 | |
void main() { | |
print('------------------FIXED LENGTH LIST------------------------'); | |
List<int> l = List(3); | |
print(l.length); |
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
/** | |
* | |
* Frequency Counter Pattern in Dart - anagram challenge | |
* | |
* Problem Description: | |
* | |
* Given two strings, write a function to determine if the second string is an anagram | |
* of the first. Do not worry about whitespace or non-alphanumeric characters. | |
* |
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
// Basic Functional Programming in Dart (as of v2.5) | |
// See live at https://dartpad.dartlang.org/8608f4b406d6fbd4504f9a328aa7b044 | |
void main() { | |
// Functions are objects | |
print('-----------------ANONYMOUS (LAMBDA) FUNCTIONS--------------------'); |
NewerOlder