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
| read -p "Please enter a file type: " filetype | |
| read -p "Please enter a directory: " filesdir | |
| if [ -z $filetype ] | |
| then | |
| echo "$filetype is empty. Please retry." | |
| exit 2 | |
| fi | |
| if [ ! -d $filesdir ] |
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
| var lengthOfLongestSubstring = function(s) { | |
| // input: string (s) | |
| // output: num (longest non consecutive string length) | |
| const sArr = s.trim().split(''); | |
| const map = new Map(); | |
| let uniqueStr = ''; | |
| let uniqueStrMax = 0; | |
| for (var i = 0; i < sArr.length; i++) { |
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
| const distributeCandies = function(candies) { | |
| if (candies.length % 2 !== 0) return candies; | |
| candies = candies.sort(function(a, b) { return a - b; }); | |
| const half = candies.length / 2; | |
| let dict = new Map(); | |
| let maxValue = Object.keys(dict).length; | |
| candies.forEach((candy, i) => { | |
| if (!dict.has(candy)) { | |
| dict.set(candy, 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
| let moves = 0; | |
| const findItem = (arr, target) => { | |
| if (!Array.isArray(arr)) return arr; | |
| moves++; | |
| const midIndex = Math.floor(arr.length / 2); | |
| const midValue = arr[midIndex]; | |
| if (target === midValue) { | |
| return midValue; |
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 { object } from 'react'; | |
| 'use strict'; | |
| class TransitionHook extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.router = this.context.router; |