├── Feb-18-2020.md ├── README.md ├── challenges ├── 100Doors │ ├── 100Doors.md │ └── solutions │ │ ├── 100Doors.js │ │ ├── 100Doors.py │ │ ├── 100Doors_2nd.js │ │ ├── 100Doors_2nd.py │ │ ├── 100_doors.rb │ │ └── objc100Doors.m ├── 2dArray │ ├── 2dArray.md │ └── solutions │ │ ├── 2dArray.js │ │ ├── 2dArray.py │ │ ├── objc2DArray.m │ │ └── pseudocode.md ├── 2ndLargestInBST │ ├── 2ndLargestInBST.md │ └── solutions │ │ ├── 2ndLargestInBST.py │ │ └── find2ndlargest.js ├── 3SumCLosest │ └── 3SumClosest.md ├── 4Sum │ └── 4Sum.md ├── CompareTwoStrings │ ├── CompareTwoStringsRepresentedAsLinkedLists.md │ └── solutions │ │ ├── CompareTwoStrings.rb │ │ ├── compareTwoStrings.cpp │ │ ├── compareTwoStrings.js │ │ ├── compare_two_linked_list_strings.rb │ │ └── compare_two_strings_solution.rb ├── FindDuplicateFileinSystem │ └── FindDuplicateFileinSystem.md ├── RangeSumQuery │ └── RangeSumQuery.md ├── SecretMessage │ ├── SecretMessage.md │ └── SecretMessage.zip ├── UglyNumber │ └── UglyNumber.md ├── addStrings │ └── addStrings.md ├── anagramDetection │ ├── anagramDetection.md │ ├── solutions │ │ └── AnagramDetection.java │ └── testing │ │ └── AnagramDetectionTest.java ├── arrayPairSum │ ├── arrayPairSum.md │ └── solutions │ │ └── arraypairsum.cpp ├── balancedParentheses │ ├── balancedParentheses.md │ └── solutions │ │ ├── balancedParentheses.js │ │ ├── balancedParentheses.py │ │ ├── balancedParentheses2.js │ │ └── objcBalancedParentheses.m ├── bestShuffle │ ├── bestShuffle.md │ └── solutions │ │ ├── bestShuffle.py │ │ └── testing │ │ └── best_shuffle_test.py ├── binarySearch │ ├── binarySearch.md │ ├── solutions │ │ └── BinarySearch.java │ └── testing │ │ └── BinarySearchTest.java ├── binaryTreePruning │ └── binaryTreePruning.md ├── bitonicPoint │ └── bitonicPoint.md ├── bubbleSort │ ├── bubbleSort.md │ └── solutions │ │ ├── BSsolution.js │ │ ├── bubbleSort.rb │ │ ├── bubble_sort.rb │ │ └── bubblesort.js ├── caesarCipher │ ├── caesarCipher.md │ └── solutions │ │ ├── TeamPython_CaeserCipher.py │ │ ├── caesarCipher.js │ │ └── objcCaesarCipher.m ├── canPlantFlowers │ └── canPlantFlowers.md ├── clique │ └── clique.md ├── clockHands │ └── clockHands.md ├── coinDenominations │ ├── coinDenominations.md │ └── solutions │ │ ├── CoinChangeCombinations.java │ │ ├── coinDenominations1.py │ │ ├── coinDenominations2.py │ │ └── coinDenominations3.py ├── containVirus │ └── containVirus.md ├── containsDuplicate │ ├── containsDuplicate.md │ └── solutions │ │ └── containsDuplicate.py ├── convertTime │ ├── ConvertTime.java │ └── convertTime.md ├── creditCardMask │ ├── ccMask.md │ └── solutions │ │ ├── ccMask.js │ │ ├── cc_mask.rb │ │ ├── cc_mask_alt.js │ │ └── credit_card_mask_solution.rb ├── cyclicalLinkedList │ ├── cyclicalLinkedList.md │ └── solutions │ │ ├── cyclicalLinkedList.js │ │ └── cyclical_linked_list.rb ├── dictionary │ ├── dictionary.md │ └── solutions │ │ ├── dictionary.cpp │ │ └── dictionary.rb ├── divisibleByBoth │ └── divisibleByBoth.md ├── double │ ├── double.md │ └── solutions │ │ ├── double.py │ │ ├── javascript.js │ │ ├── pseudocode.md │ │ └── ruby.rb ├── edgeTree │ ├── edgeTree.md │ └── solutions │ │ └── edgeTree.js ├── eggBoiler │ ├── eggBoiler.md │ └── solutions │ │ ├── Solution1.js │ │ ├── Solution1.py │ │ └── objcEggBoiler.m ├── employeeImportance │ └── employeeImportance.md ├── evenOddLetters │ ├── evenOddLetters.md │ └── solutions │ │ ├── evenOddLetters.py │ │ └── even_odd_letters.rb ├── factorial │ ├── factorial.md │ └── solutions │ │ └── factorial.rb ├── fibonacciChecker │ └── fibonacciChecker.md ├── fibonacciSum │ ├── fibonacci_sum.md │ └── solutions │ │ ├── FibonacciSum.java │ │ ├── fibosum.js │ │ ├── objcFibonacciSum.m │ │ └── ruby_fibonacci_sum.rb ├── firstDuplicate │ └── firstDuplicate.md ├── firstMissingPositive │ └── firstMissingPositive.md ├── fizzBuzz │ ├── fizzBuzz.md │ └── solutions │ │ ├── fizzBuzz.js │ │ ├── fizzBuzz.py │ │ ├── fizzBuzz.rb │ │ ├── fizzBuzz_2nd.py │ │ └── objcFizzBuzz.m ├── gcd │ └── gcd.md ├── getFileExtension │ ├── getFileExtension.md │ └── solutions │ │ ├── getFileExtension.py │ │ ├── pseudocode.md │ │ └── ruby.rb ├── getMin │ ├── getMin.md │ └── solutions │ │ └── getMin.md ├── groupAnagrams │ └── groupAnagrams.md ├── grumpyBookstoreOwner │ └── grumpyBookstoreOwner.md ├── hammingDistance │ ├── hammingDistance.md │ └── solutions │ │ └── hammingDistance.py ├── hammingDistancev2 │ └── hammingDistance.md ├── houseRobber │ ├── houseRobber.md │ └── solutions │ │ ├── houseRobber.cpp │ │ ├── houseRobber.java │ │ ├── houseRobber.js │ │ └── houseRobber.py ├── iBeforeEExceptAfterC │ └── iBeforeEExceptAfterC.md ├── insertionSort │ └── insertionSort.md ├── interleavingString │ └── interleavingString.md ├── investment │ ├── investment.md │ └── solutions │ │ ├── investment.js │ │ └── investment.rb ├── isTreeSymmetric │ ├── isTreeSymmetric.md │ └── solutions │ │ └── isTreeSymmetric.py ├── kthToLastElement │ ├── kthToLastElement.md │ └── solutions │ │ ├── kthToLastElement.js │ │ └── kthToLastElement.rb ├── largestPalindromicNumber │ ├── largest_palindromic_number.md │ └── solutions │ │ ├── objcLargestPalindromicNumber.m │ │ └── ruby_largest_palindromic_num.rb ├── largestPlusSign │ └── largestPlusSign.md ├── largestPrime │ ├── largest_prime.md │ └── solutions │ │ ├── LargestPrime.java │ │ └── ruby_largest_prime.rb ├── latticePaths │ ├── latticePaths.md │ └── solutions │ │ ├── LatticePaths.java │ │ └── latticePaths.js ├── leadersInArray │ └── leadersInArray.md ├── leftRotation │ └── leftRotation.md ├── lemonadeChange │ ├── lemonadeChange.md │ └── solutions │ │ ├── lemonadeChange.cpp │ │ ├── lemonadeChange.java │ │ └── lemonadeChange.py ├── letterCapitalize │ ├── letterCapitalize.md │ ├── solutions │ │ └── LetterCapitalize.java │ └── testing │ │ └── LetterCapitalizeTest.java ├── letterTilePossibilities │ └── letterTilePossibilities.md ├── longestCommonPrefix │ └── longestCommonPrefix.md ├── longestRange │ ├── longestRange.md │ ├── solutions │ │ ├── LongestRange.java │ │ └── longestRange.md │ └── testing │ │ └── LongestRangeTest.java ├── majorityElement │ ├── majorityElement.md │ └── solutions │ │ └── majorityElement.py ├── matchingClosingParenthesis │ ├── matchingClosingParenthesis.md │ └── solutions │ │ ├── matchingClosingParenthesis.js │ │ ├── matching_closing_parenthesis.py │ │ └── matching_closing_parenthesis.rb ├── maxConsecutiveOnes │ ├── maxConsecutiveOnes.md │ └── solutions │ │ └── maxConsecutiveOnes.py ├── maxIncreaseToKeepCitySkyline │ └── maxIncreaseToKeepCitySkyline.md ├── maximizeStockProfit │ ├── MaximizeStockProfit.java │ └── maximizeStockProfit.md ├── maximumLengthofaConcatenatedStringwithUniqueCharacters │ └── maximumLengthofaConcatenatedStringwithUniqueCharacters.md ├── medianCollection │ ├── medianCollection.md │ └── solutions │ │ └── medianCollection.rb ├── medianMaintenance │ ├── Median.txt │ ├── medianMaintenance.md │ └── solutions │ │ └── medianMaintenance.cpp ├── mergeSort │ └── mergeSort.md ├── mergeSortedLinkedLists │ └── mergeSortedLinkedLists.md ├── minimumIndexSum │ └── minimumIndexSum.md ├── minimumRotation │ └── minimumRotation.md ├── missingNumber │ └── missingNumber.md ├── mode │ ├── modequestion.js │ └── solutions │ │ ├── getMode.py │ │ ├── modeanswer.js │ │ └── simpleMode.js ├── mountainClimbers │ └── mountainClimbers.md ├── multiplesOf3And5 │ ├── multiplesOf3And5.md │ └── solutions │ │ ├── multiples3and5.py │ │ ├── multiplesOf3And5.js │ │ ├── objcMultiplesOf3And5.m │ │ └── sumOfMults.js ├── nthLeaf │ ├── nthLeaf.md │ └── solutions │ │ └── nthLeaf.rb ├── numberOfSquarefulArrays │ └── numberOfSquarefulArrays.md ├── palindrome │ ├── palindrome.md │ └── solutions │ │ ├── isPalindrome.py │ │ ├── javascript.js │ │ ├── palindrome.rb │ │ └── ruby.rb ├── partitionLabels │ └── partitionLabels.md ├── partitionLinkedList │ ├── Solutions │ │ ├── PartitionLinkedList.java │ │ ├── partitionLinkedList.cpp │ │ ├── partitionLinkedList.js │ │ └── partitionLinkedList.py │ └── partitionLinkedList.md ├── passwordGenerator │ └── passwordGenerator.md ├── perfectNumbers │ └── perfectNumbers.md ├── permutate │ ├── permutate.md │ └── solutions │ │ ├── javascript.js │ │ ├── permutate.py │ │ └── ruby.rb ├── pigLatin │ ├── pigLatin.md │ └── solutions │ │ ├── pigLatin.js │ │ ├── pigLatin.py │ │ └── pigLatin.rb ├── powerOfTwo │ ├── powerOfTwo.md │ └── solutions │ │ ├── powerOfTwo.cpp │ │ ├── powerOfTwo.py │ │ └── powerOfTwo.rb ├── powerSet │ ├── powerSet.md │ └── solutions │ │ └── powerSet.py ├── primeFactors │ ├── primeFactors.md │ └── solutions │ │ ├── largestPrimeFactor.py │ │ └── primeFactors.js ├── primeSum │ └── primeSum.md ├── primesBase10 │ ├── primesBase10.md │ └── solutions │ │ └── primesBase10.py ├── priorityQueue │ └── priorityQueue.md ├── productOfIntegers │ ├── productOfIntegers.md │ └── solutions │ │ ├── productOfIntegers.js │ │ └── productOfIntegers.py ├── quickSort │ ├── quickSort.md │ └── solutions │ │ ├── QuickSort.txt │ │ ├── quickSort.cpp │ │ └── quickSort.js ├── rainWaterCollector │ ├── rainWaterCollector.md │ └── solutions │ │ └── rainWaterCollector.js ├── range │ ├── range.md │ └── solutions │ │ ├── Range.java │ │ ├── objcRange.m │ │ └── range.js ├── removeDuplicatesInString │ └── removeDuplicatesInString.md ├── removeDuplicatesInStringII │ └── removeDuplicatesInStringII.md ├── removeVowels │ ├── removeVowels.md │ └── solutions │ │ ├── pseudocode.md │ │ ├── removeVowels.php │ │ ├── removeVowels.py │ │ └── removeVowels.rb ├── repeatify │ ├── repeatify.md │ └── solutions │ │ ├── javascript.js │ │ ├── objcRepeatify.m │ │ ├── repeatify.py │ │ └── ruby.rb ├── reverse │ ├── reverse.md │ └── solutions │ │ ├── javascript.js │ │ ├── reverce.py │ │ ├── reverse.js │ │ └── ruby.rb ├── reverseInteger │ └── reverseInteger.md ├── reverseSublist │ ├── reverseSublist.md │ └── solutions │ │ ├── reverseSublist.cpp │ │ ├── reverseSublist.scala │ │ └── reverseSublistSolution.java ├── rockPaperScissors │ ├── rockPaperScissors.md │ └── solutions │ │ ├── rocksPaperScissors.js │ │ └── rocksPaperScissors.py ├── romanNumerals │ ├── romanNumerals.md │ ├── solutions │ │ ├── roman_numerals.java │ │ └── roman_numerals.rb │ └── spec │ │ └── roman_numerals_spec.rb ├── rotateMatrix │ └── rotateMatrix.md ├── searchInsertPosition │ └── searchInsertPosition.md ├── segregateEvenOdd │ ├── segregateEvenOdd.js │ └── segregateEvenOdd.md ├── selectionSort │ ├── selectionSort.md │ └── solutions │ │ └── SelectionSort.java ├── selfDescribingNumbers │ ├── selfDescribingNumbers.md │ ├── solutions │ │ └── SelfDescribingNumbers.java │ └── testing │ │ └── SelfDescribingNumbersTest.java ├── seriesSum │ ├── seriesSum.md │ └── solutions │ │ ├── Solution2.js │ │ ├── Solution2.py │ │ ├── Solution2.rb │ │ ├── Solution3.js │ │ └── objcSeriesSum.m ├── sevenSidedDice │ └── sevenSidedDice.md ├── sharePrice │ ├── sharePrice.md │ └── solutions │ │ └── sharePrice.js ├── sieveOfEratosthenes │ ├── sieveOfEratosthenes.md │ └── solutions │ │ ├── sieveOfErathosthenes.rb │ │ ├── sieveOfEratosthenes.js │ │ └── sieveOfEratosthenes.rb ├── singleNumber │ └── singleNumber.md ├── smallestSubarray │ └── smallestSubarray.md ├── sockMerchant │ └── sockMerchant.md ├── spellNumber │ └── spellNumber.md ├── string2Int │ ├── solutions │ │ └── string2Int.cpp │ └── string2Int.md ├── stringCount │ └── stringCount.md ├── stripWhitespace │ └── stripWhitespace.md ├── sudoku │ ├── solutions │ │ ├── Sudoku.java │ │ ├── sudoku.js │ │ ├── sudoku2.js │ │ └── sudoku_checker_solution.rb │ └── sudoku.md ├── sumPairs │ ├── solutions │ │ ├── Ruby-optimized.rb │ │ ├── sumPairs.js │ │ └── sumPairs.rb │ └── sumPairs.md ├── sumSquareDifference │ ├── solutions │ │ ├── objcSumSquareDifference.m │ │ ├── ruby_sum_square_diff.rb │ │ └── swiftSumSquareDifference.playground │ └── sum_square_difference.md ├── sumsOfN │ ├── solutions │ │ └── sumsOfN.js │ └── sumsOfN.md ├── ticTacToe │ └── ticTacToe.md ├── timeConversion │ ├── solutions │ │ ├── Solution1.js │ │ ├── TimeConversion.java │ │ ├── convert_time.py │ │ ├── solution2.js │ │ ├── team_macj.js │ │ ├── testing │ │ │ ├── README.md │ │ │ ├── spec │ │ │ │ └── time_conversion_spec.rb │ │ │ └── test │ │ │ │ └── time_conversion_test.js │ │ ├── time_conversion.js │ │ └── time_conversion.rb │ └── timeConversion.md ├── towersOfHanoi │ ├── solutions │ │ ├── towersOfHanoi.js │ │ └── towersOfHanoi.py │ └── towersOfHanoi.md ├── tr │ ├── .DS_Store │ ├── solutions │ │ ├── tr.js │ │ ├── tr.py │ │ ├── tr.rb │ │ ├── tr_swift.playground │ │ │ ├── Contents.swift │ │ │ ├── contents.xcplayground │ │ │ └── playground.xcworkspace │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ └── xcuserdata │ │ │ │ └── ericamillado.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ └── tr_translate.py │ └── tr.md ├── triangleInequality │ ├── solutions │ │ ├── TriangleInequality.java │ │ ├── swiftTriangleInequality.playground │ │ └── triangleInequality.py │ └── triangleInequality.md ├── tribonacci │ ├── solutions │ │ ├── Tribonacci.java │ │ ├── tribonacci.js │ │ ├── tribonacci.rb │ │ └── tribonacci_solution.rb │ └── tribonacci.md ├── twoKeyKeyboard │ └── twoKeyKeyboard.md ├── twoSum │ ├── solutions │ │ ├── twoSum.py │ │ ├── twoSum_02.py │ │ └── two_sum.rb │ └── twoSum.md ├── uniquePaths │ └── uniquePaths.md ├── validTic-Tac-Toe State │ └── validTic-Tac-Toe State.md ├── validateIP │ └── validateIP.md ├── vowelSquare │ └── vowelSquare.md ├── waysToCoverDistance │ └── waysToCoverDistance.md └── wordSearch │ ├── solutions │ └── wordSearch.py │ └── wordSearch.md ├── gitGuide.md ├── howToContribute.md ├── images ├── branch.png ├── clone.png ├── clone2.png ├── commit.png ├── first.png ├── pullRequest.png └── pullRequest2.png └── past-events ├── April-16-2019.md ├── April-18-2018.md ├── April-19-2017.md ├── April-28-2016.md ├── August-11-2016.md ├── August-16-2017.md ├── August-19-2015.md ├── August-20-2019.md ├── August-21-2018.md ├── December-19-2018.md ├── February-16-2017.md ├── February-18-2016.md ├── February-19-2019.md ├── February-21-2018.md ├── January-15-2019.md ├── January-17-2017.md ├── January-17-2018.md ├── January-20-2016.md ├── July-13-2016.md ├── July-16-2015.md ├── July-16-2019.md ├── July-17-2018.md ├── July-20-2017.md ├── June-15-2016.md ├── June-18.md ├── June-19-2018.md ├── June-21-2017.md ├── March-15-2017.md ├── March-17-2016.md ├── March-19-2019.md ├── May-17-2018.md ├── May-18-2016.md ├── May-21-2019.md ├── May-25-2017.md ├── November-16-2016.md ├── November-18-2015.md ├── November-29-2017.md ├── October-13-2016.md ├── October-16-2018.md ├── October-18-2017.md ├── October-22-2015.md ├── September-15-2015.md ├── September-18-2018.md ├── September-20-2017.md └── September-21-2016.md /challenges/100Doors/100Doors.md: -------------------------------------------------------------------------------- 1 | #Problem: 2 | You have 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, you visit every door and toggle the door (if the door is closed, you open it; if it is open, you close it). The second time you only visit every 2nd door (door #2, #4, #6, ...). The third time, every 3rd door (door #3, #6, #9, ...), etc, until you only visit the 100th door. 3 | 4 | What state are the doors in after the last pass? Which are open, which are closed? 5 | 6 | ## Source 7 | http://rosettacode.org/wiki/100_doors 8 | -------------------------------------------------------------------------------- /challenges/100Doors/solutions/100Doors.js: -------------------------------------------------------------------------------- 1 | for (var door = 1; door <= 100; door++) { 2 | var sqrt = Math.sqrt(door); 3 | if (sqrt === (sqrt | 0)) { 4 | console.log("Door %d is open", door); 5 | } 6 | } 7 | 8 | // solution from http://rosettacode.org/wiki/100_doors#JavaScript 9 | -------------------------------------------------------------------------------- /challenges/100Doors/solutions/100Doors.py: -------------------------------------------------------------------------------- 1 | def timesforfinalclose(times): 2 | 3 | array_Init = [] 4 | for i in range(0,times): 5 | array_Init.append(0) 6 | for n in range(1,times+1): 7 | for i in range(n, times): 8 | if i % n == 0: 9 | array_Init[i-1] = 1 - array_Init[i-1] 10 | return array_Init 11 | 12 | print timesforfinalclose(100) 13 | 14 | ## submitted by [jungjung917](https://github.com/jungjung917) 15 | -------------------------------------------------------------------------------- /challenges/100Doors/solutions/100Doors_2nd.py: -------------------------------------------------------------------------------- 1 | import math 2 | def door100(): 3 | for i in range(1, int(math.sqrt(100)+1)): 4 | print ("%sth door is open\n" % (i*i)) 5 | 6 | door100() 7 | 8 | ## submitted by [jungjung917](https://github.com/jungjung917) 9 | -------------------------------------------------------------------------------- /challenges/100Doors/solutions/100_doors.rb: -------------------------------------------------------------------------------- 1 | def hundred_doors 2 | 100.times do |index| 3 | door_number = index + 1 4 | if (door_number % 2) == 0 && (door_number % 3) == 0 5 | puts "door number #{door_number} is closed" 6 | elsif door_number % 2 == 0 || door_number % 3 == 0 7 | puts "door number #{door_number} is open" 8 | else 9 | puts "door number #{door_number} is closed" 10 | end 11 | 12 | end 13 | end 14 | 15 | hundred_doors 16 | 17 | # sample output 18 | # door number 1 is closed 19 | # door number 2 is open 20 | # door number 3 is open 21 | # door number 4 is open 22 | # door number 5 is closed 23 | # door number 6 is closed 24 | # ... 25 | -------------------------------------------------------------------------------- /challenges/2dArray/2dArray.md: -------------------------------------------------------------------------------- 1 | **Level 2**
2 | Write a function that takes in a 2-D array that represents a square matrix and returns the product of the diagonal of the matrix. For example 3 | [ [ 2, 3], 4 | [ 4, 5] ] 5 | will return 10 (2x5). 6 | 7 | submitted by [seemaullal](https://github.com/seemaullal) 8 | -------------------------------------------------------------------------------- /challenges/2dArray/solutions/2dArray.py: -------------------------------------------------------------------------------- 1 | """Level 2 2 | Write a function that takes in a 2-D array that represents a square 3 | matrix and returns the product of the diagonal of the matrix. 4 | For example [ [ 2, 3], [ 4, 5] ] will return 10 (2x5).""" 5 | 6 | def diagonalMatrix(inputArray): 7 | diagonal = 1 8 | for i in range(0,len(inputArray)): 9 | diagonal = diagonal * inputArray[i][i] 10 | return diagonal 11 | print diagonalMatrix([[2,3],[4,5]]) 12 | 13 | 14 | ## submitted by [jungjung917](https://github.com/jungjung917) 15 | -------------------------------------------------------------------------------- /challenges/2dArray/solutions/objc2DArray.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 2dArray 4 | // 5 | // Created by Julianne on 7/21/16. 6 | // Copyright © 2016 Julianne Goyena. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int productOfDiagonal(int array[2][2]) { 12 | 13 | int product = array[0][0] * array[1][1]; 14 | 15 | return product; 16 | } 17 | 18 | int main(int argc, const char * argv[]) { 19 | @autoreleasepool { 20 | 21 | // Write a function that takes in a 2-D array that represents a square matrix and returns the product of the diagonal of the matrix. For example [ [ 2, 3], [ 4, 5] ] will return 10 (2x5). 22 | 23 | int array[2][2] = { 24 | {2, 3}, 25 | {4, 5} 26 | }; 27 | 28 | int product = productOfDiagonal(array); 29 | NSLog(@"The product of %i and %i is %i", array[0][0], array[1][1], product); // The product of 2 and 5 is 10 30 | 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /challenges/2ndLargestInBST/2ndLargestInBST.md: -------------------------------------------------------------------------------- 1 | ## Find the 2 largest element in BST(binary search tree): 2 | 3 | Write a function to find the 2nd largest element in a binary search tree: 4 | 5 | *A binary search tree is a binary tree in which, for each node: 6 | 7 | * The node's value is greater than all values in the left subtree. 8 | * The node's value is less than all values in the right subtree. 9 | BSTs are useful for quick lookups. If the tree is balanced, we can search for a given value in the tree in O(lgn) time.* 10 | -------------------------------------------------------------------------------- /challenges/3SumCLosest/3SumClosest.md: -------------------------------------------------------------------------------- 1 | # 3Sum Closest 2 | 3 | ## Problem 4 | 5 | Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. 6 | Return the sum of the three integers. You may assume that each input would have exactly one solution. 7 | ## Example 8 | 9 | Given array nums = [-1, 2, 1, -4], and target = 1. 10 | 11 | The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). 12 | 13 | [Source](https://leetcode.com/problems/3sum-closest/) 14 | -------------------------------------------------------------------------------- /challenges/4Sum/4Sum.md: -------------------------------------------------------------------------------- 1 | # 4Sum 2 | 3 | ## Problem 4 | 5 | Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. 6 | 7 | Note: 8 | 9 | The solution set must not contain duplicate quadruplets. 10 | 11 | ## Example 12 | 13 | ``` 14 | Given array nums = [1, 0, -1, 0, -2, 2], and target = 0. 15 | 16 | A solution set is: 17 | [ 18 | [-1, 0, 0, 1], 19 | [-2, -1, 1, 2], 20 | [-2, 0, 0, 2] 21 | ] 22 | 23 | ``` 24 | 25 | [Source](https://leetcode.com/problems/4sum/) 26 | -------------------------------------------------------------------------------- /challenges/CompareTwoStrings/solutions/compareTwoStrings.js: -------------------------------------------------------------------------------- 1 | function Node (val) { 2 | this.value = val 3 | this.next = null 4 | } 5 | 6 | Node.prototype.add = function (val) { 7 | let node = this 8 | while (node.next) { 9 | node = node.next 10 | } 11 | node.next = new Node(val) 12 | } 13 | 14 | function compareTwoStrings (a, b) { 15 | let currA = a 16 | let currB = b 17 | //iterate as long as letters are same and lists are not consumed 18 | while(currA && currB && currA.value === currB.value) { 19 | currA = currA.next 20 | currB = currB.next 21 | } 22 | if(!currA && !currB) return 0 23 | //b is longer or if a still has a value, compare 24 | else if(!currA && currB || currA.value < currA && currB.value) return -1 25 | //a is longer or if b still has a value, compare 26 | else if(!currB && currA || currA.value > currB && currB.value) return 1 27 | } 28 | 29 | let listA = new Node('c') 30 | listA.add('a') 31 | listA.add('t') 32 | listA.add('s') 33 | 34 | let listB = new Node('c') 35 | listB.add('a') 36 | listB.add('t') 37 | 38 | compareTwoStrings(listA, listB) 39 | -------------------------------------------------------------------------------- /challenges/CompareTwoStrings/solutions/compare_two_strings_solution.rb: -------------------------------------------------------------------------------- 1 | def compare_two_strings(string_one, string_two) 2 | string_one <=> string_two 3 | end 4 | 5 | p compare_two_strings("g->e->e->k->s", "g->e->e->k->s") 6 | # 0 7 | 8 | p compare_two_strings("g->e->e->k->s->a", "g->e->e->k->s") 9 | # 1 10 | 11 | p compare_two_strings("g->e->e->k->s->a", "g->e->e->k->s->b") 12 | # -1 13 | 14 | 15 | =begin 16 | 17 | Input: 18 | list1 = g->e->e->k->s 19 | list2 = g->e->e->k->s 20 | Output: 0 21 | 22 | Input: 23 | list1 = g->e->e->k->s->a 24 | list2 = g->e->e->k->s 25 | Output: 1 26 | 27 | Input: 28 | list1 = g->e->e->k->s->a 29 | list2 = g->e->e->k->s->b 30 | Output: -1 31 | 32 | =end 33 | -------------------------------------------------------------------------------- /challenges/RangeSumQuery/RangeSumQuery.md: -------------------------------------------------------------------------------- 1 | # Range Sum Query - Immutable 2 | 3 | ## Problem 4 | Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. 5 | 6 | Note: 7 | 8 | You may assume that the array does not change. 9 | There are many calls to sumRange function 10 | 11 | ## Example 12 | 13 | ``` 14 | Given nums = [-2, 0, 3, -5, 2, -1] 15 | 16 | sumRange(0, 2) -> 1 17 | sumRange(2, 5) -> -1 18 | sumRange(0, 5) -> -3 19 | 20 | ``` 21 | 22 | [Source](https://leetcode.com/problems/range-sum-query-immutable/) 23 | -------------------------------------------------------------------------------- /challenges/SecretMessage/SecretMessage.md: -------------------------------------------------------------------------------- 1 | Write a program to remove numerical characters from the picture file names. (To see file names download the repo and navigate to the SecretMessage Zip file). Once complete, the pictures will reveal a secret message. 2 | 3 | Source: Udacity - Intro to Programming with Python 4 | -------------------------------------------------------------------------------- /challenges/SecretMessage/SecretMessage.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WomenWhoCodeNYC/Algorithms/69bd06b806826392b7d0d675fe6f9966d592f48c/challenges/SecretMessage/SecretMessage.zip -------------------------------------------------------------------------------- /challenges/UglyNumber/UglyNumber.md: -------------------------------------------------------------------------------- 1 | # Ugly Number 2 | 3 | ## Problem 4 | 5 | Write a program to check whether a given number is an ugly number. 6 | Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. 7 | 8 | ## Example 9 | 10 | ``` 11 | Input: 6 12 | Output: true 13 | Explanation: 6 = 2 × 3 14 | ``` 15 | ``` 16 | Input: 14 17 | Output: false 18 | Explanation: 14 is not ugly since it includes another prime factor 7. 19 | 20 | ``` 21 | [Source](https://leetcode.com/problems/ugly-number/) 22 | -------------------------------------------------------------------------------- /challenges/addStrings/addStrings.md: -------------------------------------------------------------------------------- 1 | ## LeetCode - Easy. Add Strings 2 | ## Problem 3 | Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. 4 | ``` 5 | Note: 6 | 7 | The length of both num1 and num2 is < 5100. 8 | Both num1 and num2 contains only digits 0-9. 9 | Both num1 and num2 does not contain any leading zero. 10 | You must not use any built-in BigInteger library or convert the inputs to integer directly. 11 | ``` 12 | [Source](https://leetcode.com/problems/add-strings/) 13 | -------------------------------------------------------------------------------- /challenges/anagramDetection/anagramDetection.md: -------------------------------------------------------------------------------- 1 | ## Anagram Detection 2 | 3 | Write a function that accepts two parameters, a parent and a child string. The function should return how many times the child string, or an anagram of the child string, appears in the parent string. (There is a solution which can be done in near instant time!) 4 | 5 | #### Example: 6 | 7 | ```javascript 8 | f('AdnBndAndBdaBn', 'dAn') 9 | // 4 ("Adn", "ndA", "dAn", "And") 10 | 11 | f('AbrAcadAbRa', 'cAda') 12 | // 2 13 | ``` 14 | 15 | Source: https://github.com/blakeembrey/code-problems/tree/master/problems/anagram-detection 16 | -------------------------------------------------------------------------------- /challenges/anagramDetection/solutions/AnagramDetection.java: -------------------------------------------------------------------------------- 1 | package solutions; 2 | 3 | import java.util.Arrays; 4 | 5 | public class AnagramDetection { 6 | public static int count(String parent, String child) { 7 | int count = 0; 8 | 9 | for (int i = 0; i < parent.length(); i++) { 10 | if (anagramStarts(parent, child, i)) { 11 | count++; 12 | } 13 | } 14 | 15 | return count; 16 | } 17 | 18 | private static boolean anagramStarts(String parent, String child, int i) { 19 | int j = i + child.length(); 20 | 21 | if (j > parent.length()) { 22 | return false; 23 | } 24 | 25 | char[] parentChars = parent.substring(i, j).toCharArray(); 26 | char[] childChars = child.toCharArray(); 27 | 28 | Arrays.sort(parentChars); 29 | Arrays.sort(childChars); 30 | return Arrays.equals(parentChars, childChars); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /challenges/anagramDetection/testing/AnagramDetectionTest.java: -------------------------------------------------------------------------------- 1 | package solutions; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | public class AnagramDetectionTest { 8 | 9 | @Test 10 | public void test1() { 11 | String parent = "AdnBndAndBdaBn"; 12 | String child = "dAn"; 13 | 14 | int expected = 4; 15 | int actual = AnagramDetection.count(parent, child); 16 | assertEquals(expected, actual); 17 | } 18 | 19 | 20 | @Test 21 | public void test2() { 22 | String parent = "AbrAcadAbRa"; 23 | String child = "cAda"; 24 | 25 | int expected = 2; 26 | int actual = AnagramDetection.count(parent, child); 27 | assertEquals(expected, actual); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /challenges/arrayPairSum/arrayPairSum.md: -------------------------------------------------------------------------------- 1 | # Array Pair Sum 2 | 3 | ## Problem 4 | 5 | Given an integer array, output all pairs that sum up to a specific value k. 6 | 7 | ## Example 8 | ```javascript 9 | f([3, 8, 6, 11, 94, 1], 9) 10 | // => [[3, 6], [8, 1]] 11 | ``` 12 | 13 | [Source](http://www.ardendertat.com/2011/09/17/programming-interview-questions-1-array-pair-sum/) 14 | -------------------------------------------------------------------------------- /challenges/balancedParentheses/balancedParentheses.md: -------------------------------------------------------------------------------- 1 | ## Balanced Parentheses 2 | Problem found on [StackExchange](http://codereview.stackexchange.com/questions/45916/check-for-balanced-parentheses) 3 | 4 | Given a string, determine if the Parentheses, Braces, and Brackets are properly balanced. 5 | 6 | For example, the program should print true for 7 | ``` 8 | exp = "[()]{}{[()()]()}" 9 | ``` 10 | and false for 11 | ``` 12 | exp = "[(])" 13 | ``` 14 | -------------------------------------------------------------------------------- /challenges/balancedParentheses/solutions/balancedParentheses.js: -------------------------------------------------------------------------------- 1 | var isBalanced = function(str) { 2 | var stack = []; 3 | var parenthesesHash = { 4 | '[':']', 5 | '(':')', 6 | '{':'}' 7 | }; 8 | 9 | if (str.length === 0) { 10 | return 'String length should be greater than 0'; 11 | } 12 | 13 | if (str.length % 2 !== 0) { 14 | return false; 15 | } 16 | 17 | for (var i = 0; i < str.length; i++) { 18 | var char = str.charAt(i); 19 | if (parenthesesHash[char]) { 20 | stack.push(char); 21 | } else if (char !== parenthesesHash[stack.pop()]) { 22 | return false; 23 | } 24 | } 25 | 26 | return true; 27 | } 28 | 29 | console.log(isBalanced('[()]{}{[()()]()}')); // return true 30 | console.log(isBalanced('[()]{}{[()(]()}')); // return false 31 | console.log(isBalanced('[{{]')); // return false 32 | console.log(isBalanced('')); // return 'String length should be greater than 0' 33 | -------------------------------------------------------------------------------- /challenges/balancedParentheses/solutions/balancedParentheses2.js: -------------------------------------------------------------------------------- 1 | function matchBraces(string) { 2 | 3 | if (string.length % 2 !== 0) return false; 4 | var brackets = ["()", "[]", "{}"]; 5 | 6 | function checkBrackets(reducedString) { 7 | var countReduction = 0; 8 | brackets.forEach(function(bracket) { 9 | var originalLength = reducedString.length; 10 | reducedString = reducedString.split(bracket).join(''); 11 | if (originalLength !== reducedString.length) countReduction++; 12 | }); 13 | if (reducedString === '') return true; 14 | if (countReduction === 0) return false; 15 | return checkBrackets(reducedString); 16 | } 17 | return checkBrackets(string); 18 | } 19 | 20 | matchBraces("(){}[][[]](())"); 21 | 22 | //submitted by Tiffany Poss https://github.com/tiffanyposs -------------------------------------------------------------------------------- /challenges/bestShuffle/bestShuffle.md: -------------------------------------------------------------------------------- 1 | # Best Shuffle 2 | 3 | ## Problem 4 | 5 | Shuffle the characters of a string in such a way that as many of the character values are in a different position as possible. 6 | 7 | A shuffle that produces a randomized result among the best choices is preferred, but a deterministic approach that produces the same sequence every time is okay. 8 | 9 | Display the result as follows: 10 | 11 | ``` 12 | original string, shuffled string, score 13 | ``` 14 | 15 | The score gives the number of positions whose character value did not change. 16 | 17 | ## Example 18 | 19 | ```javascript 20 | f(corgi); 21 | # => corgi, irogc, (0) 22 | 23 | f(a); 24 | # => a, a, (1) 25 | ``` 26 | 27 | [Source](http://rosettacode.org/wiki/Best_shuffle) 28 | -------------------------------------------------------------------------------- /challenges/binarySearch/binarySearch.md: -------------------------------------------------------------------------------- 1 | ## Binary search 2 | 3 | What's binary search? Let's have our old friend Wikipedia tell us a little about it! 4 | 5 | > In computer science, binary search...is a search algorithm that finds the position of a target value within a sorted array. 6 | 7 | Great! What are the steps it takes? 8 | 9 | > Binary search compares the target value to the middle element of the array; if they are unequal, the half in which the target cannot lie is eliminated and the search continues on the remaining half until it is successful. If the search ends with the remaining half being empty, the target is not in the array. 10 | 11 | So, write a function that uses those steps to find the index of a given element within a sorted array. 12 | 13 | #### Example: 14 | 15 | ```javascript 16 | f([0, 1, 4, 9, 15, 22, 22, 59], 9) 17 | // 3 18 | ``` 19 | -------------------------------------------------------------------------------- /challenges/binarySearch/solutions/BinarySearch.java: -------------------------------------------------------------------------------- 1 | package solutions; 2 | 3 | public class BinarySearch { 4 | public static int find(int[] arr, int n) { 5 | return find(arr, n, 0, arr.length - 1); 6 | } 7 | 8 | private static int find(int[] arr, int n, int i, int j) { 9 | int mid = (i + j) / 2; 10 | 11 | if (i > j) 12 | return -1; 13 | 14 | if (arr[mid] == n) 15 | return mid; 16 | 17 | if (n < arr[mid]) 18 | return find(arr, n, i, mid - 1); 19 | else 20 | return find(arr, n, mid + 1, j); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /challenges/binarySearch/testing/BinarySearchTest.java: -------------------------------------------------------------------------------- 1 | package solutions; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | public class BinarySearchTest { 8 | 9 | @Test 10 | public void test1() { 11 | int expected = 3; 12 | int actual = BinarySearch.find(new int[]{0, 1, 4, 9, 15, 22, 22, 59}, 9); 13 | assertEquals(expected, actual); 14 | } 15 | 16 | @Test 17 | public void test2() { 18 | int expected = 7; 19 | int actual = BinarySearch.find(new int[]{0, 1, 4, 9, 15, 22, 22, 59}, 59); 20 | assertEquals(expected, actual); 21 | } 22 | 23 | @Test 24 | public void test4() { 25 | int expected = -1; 26 | int actual = BinarySearch.find(new int[]{0, 1, 4, 9, 15, 22, 22, 59}, 100); 27 | assertEquals(expected, actual); 28 | } 29 | 30 | @Test 31 | public void test3() { 32 | int actual = BinarySearch.find(new int[]{0, 1, 4, 9, 15, 22, 22, 59}, 22); 33 | assertTrue(actual == 5 || actual == 6); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /challenges/binaryTreePruning/binaryTreePruning.md: -------------------------------------------------------------------------------- 1 | # Binary Tree Pruning 2 | 3 | ## Problem 4 | 5 | We are given the head node root of a binary tree, where additionally every node's value is either a 0 or a 1. 6 | 7 | Return the same tree where every subtree (of the given tree) not containing a 1 has been removed. 8 | 9 | (Recall that the subtree of a node X is X, plus every node that is a descendant of X.) 10 | ``` 11 | Example 1: 12 | Input: [1,null,0,0,1] 13 | Output: [1,null,0,null,1] 14 | ``` 15 | 16 | ``` 17 | Example 2: 18 | Input: [1,0,1,0,0,0,1] 19 | Output: [1,null,1,null,1] 20 | ``` 21 | ``` 22 | Example 3: 23 | Input: [1,1,0,1,1,0,1,0] 24 | Output: [1,1,0,1,1,null,1] 25 | 26 | ``` 27 | 28 | Note: 29 | 30 | The binary tree will have at most 100 nodes. 31 | The value of each node will only be 0 or 1. 32 | 33 | Check source link for explanations 34 | 35 | [Source](https://leetcode.com/problems/binary-tree-pruning/) 36 | -------------------------------------------------------------------------------- /challenges/bitonicPoint/bitonicPoint.md: -------------------------------------------------------------------------------- 1 | ### Bitonic Point Detection 2 | 3 | Given an array of integers that is initially increasing and then decreasing (a bitonic sequence), find the index of the peak (the bitonic point). 4 | 5 | Hint: There's a solution that is O(n) and one that is O(log(n))! 6 | 7 | Example: 8 | ``` 9 | Input: [2, 3, 4, 5, 2, 1] 10 | 11 | Output: 3 12 | ``` 13 | 14 | [Source](https://www.geeksforgeeks.org/find-bitonic-point-given-bitonic-sequence/) 15 | -------------------------------------------------------------------------------- /challenges/bubbleSort/solutions/BSsolution.js: -------------------------------------------------------------------------------- 1 | I worked alongside Ryan Richard to figure out the bubble sorting prompt, this was our solution: 2 | var a = [5, 1, 4, 2,8] 3 | 4 | function bubbleBlue(a) { 5 | var l, m; 6 | for (var i= a.length-1; i >= 0; i--){ 7 | for(m = 0; m <= i; m++){ 8 | if(a[m+1] str[n] 9 | str[n-1], str[n] = str[n], str[n-1] 10 | sorted = false 11 | end 12 | end 13 | end 14 | str 15 | end 16 | 17 | 18 | print bubble_sort(str: "zjbbca") -------------------------------------------------------------------------------- /challenges/bubbleSort/solutions/bubble_sort.rb: -------------------------------------------------------------------------------- 1 | def bubble_sort(array) 2 | constant_array = array.to_s 3 | 4 | array.each do |num| 5 | i = array.index(num) 6 | next_index = i + 1 7 | 8 | if array[next_index] 9 | next_num = array[next_index] 10 | if num > next_num 11 | array[i] = next_num 12 | array[next_index] = num 13 | end 14 | end 15 | 16 | end 17 | 18 | if array.to_s != constant_array 19 | bubble_sort(array) 20 | end 21 | 22 | array 23 | 24 | end 25 | 26 | print bubble_sort([5, 1, 4, 2, 8]) 27 | # expect [1, 2, 4, 5, 8] -------------------------------------------------------------------------------- /challenges/bubbleSort/solutions/bubblesort.js: -------------------------------------------------------------------------------- 1 | var a = [5, 1, 4, 2, 8]; 2 | function bubblesort (a) { 3 | let swap = true; 4 | 5 | while(swap) { 6 | swap = false; 7 | for ( let i = 0; i < a.length; i++) { 8 | if ( a[i] > a[i+1]) { 9 | [a[i], a[i+1]] = [a[i+1], a[i]]; 10 | swap = true; 11 | console.log(swap); 12 | console.log(a); 13 | } 14 | } 15 | } 16 | 17 | return a 18 | } 19 | 20 | console.log(a) 21 | 22 | bubblesort(a) -------------------------------------------------------------------------------- /challenges/caesarCipher/caesarCipher.md: -------------------------------------------------------------------------------- 1 | Create a [Caesar Cipher](https://en.wikipedia.org/wiki/Caesar_cipher) 2 | 3 | With a Caesar Cipher you are giving a key (say the number 3) and all of the letters of the alphabet rotate that many number of spaces over. Can you create a function that can encrypt/decrypt a message using the ceasar cipher? 4 | 5 | Extreme bonus points for creating a decrypter than can decrypt caesar's cipher without a key. 6 | -------------------------------------------------------------------------------- /challenges/caesarCipher/solutions/TeamPython_CaeserCipher.py: -------------------------------------------------------------------------------- 1 | #Caesar Cipher 2 | import string 3 | 4 | def cipher(string, key, encode= True): 5 | string = string.lower() 6 | returnstr = "" 7 | letters= string.lowercase 8 | 9 | if (not encode): 10 | key = -key 11 | 12 | for ch in string: 13 | returnstr += letters[((letters.index(ch) + key)%26)] 14 | 15 | return returnstr 16 | 17 | 18 | -------------------------------------------------------------------------------- /challenges/caesarCipher/solutions/caesarCipher.js: -------------------------------------------------------------------------------- 1 | /*github: @JuiceCrawl, @ashes74, @Junkyard4000, @RyanFairist, @si74, @jes_andra*/ 2 | 3 | 4 | function getNewCode(code,key){ 5 | var result; 6 | if (code >= 97 && code <= 122){ 7 | result = ((code + key - 96) % 26) + 96; 8 | }else if(code >= 65 && code <= 90){ 9 | result = ((code + key - 64) % 26) + 64; 10 | }else{ 11 | result = code; 12 | } 13 | return result; 14 | } 15 | 16 | function cencrypt(s, key){ 17 | var result = ""; 18 | for (i = 0 ; i < s.length; i++){ 19 | var code = s.charCodeAt(i); 20 | result += String.fromCharCode(getNewCode(code,key)); 21 | } 22 | return result; 23 | } 24 | 25 | console.log(cencrypt("zFabc",3)); 26 | -------------------------------------------------------------------------------- /challenges/canPlantFlowers/canPlantFlowers.md: -------------------------------------------------------------------------------- 1 | # Can plant flowers 2 | 3 | ## Problem 4 | 5 | Suppose you have a long flowerbed in which some of the plots are planted and some are not. 6 | However, flowers cannot be planted in adjacent plots - they would compete for water and both would die. 7 | 8 | Given a flowerbed (represented as an array containing 0 and 1, where 0 means empty and 1 means not empty) and a number _n_, return true or false indicating whether _n_ new flowers can be planted in it without violating the no adjacent flowers" rule. 9 | 10 | ## Example 11 | 12 | ``` 13 | Input: flowerbed = [1,0,0,0,1], n = 1 14 | 15 | Output: True 16 | ``` 17 | 18 | ``` 19 | Input: flowerbed = [1,0,0,0,1], n = 2 20 | 21 | Output: False 22 | ``` 23 | 24 | [Source](https://leetcode.com/problems/can-place-flowers/) 25 | -------------------------------------------------------------------------------- /challenges/clockHands/clockHands.md: -------------------------------------------------------------------------------- 1 | # Clock hands 2 | 3 | ## Problem 4 | 5 | Write a function that takes an integer that represents where the minute hand currently is on 6 | a clock, and returns the angle formed by the minute hand and the 12 o'clock mark. 7 | 8 | ## Example 9 | 10 | ```javascript 11 | f(15) 12 | // => 90 13 | ``` 14 | 15 | ## Extra credit 16 | 17 | Write a function that takes two integers that represent the hour and minute values of a 18 | time, and returns the angle formed by the hour and minute hand on a clock. Keep in 19 | mind that the hour hand advances as the minute hands do. 20 | 21 | [Source](https://coderbyte.com/algorithm/simple-clock-angle) 22 | -------------------------------------------------------------------------------- /challenges/coinDenominations/coinDenominations.md: -------------------------------------------------------------------------------- 1 | ##Coin denominations 2 | 3 | Imagine you landed a new job as a cashier... 4 | Your quirky boss found out that you're a programmer and has a weird request about something they've been wondering for a long time. 5 | 6 | Write a function that, given: 7 | 8 | * an amount of money 9 | * an array of coin denominations 10 | 11 | computes the number of ways to make amount of money with coins of the available denominations. 12 | 13 | Example: for amount=4 (4¢) and denominations=[1,2,3] (1¢, 2¢ and 3¢), your program would output 4—the number of ways to make 4¢: 14 | 15 | *1¢, 1¢, 1¢, 1¢ 16 | 1¢, 1¢, 2¢ 17 | 1¢, 3¢ 18 | 2¢, 2¢* 19 | 20 | submitted by [Iuliia Kotlenko](https://github.com/IuliiaKot) 21 | -------------------------------------------------------------------------------- /challenges/coinDenominations/solutions/coinDenominations1.py: -------------------------------------------------------------------------------- 1 | from copy import deepcopy 2 | 3 | # assumes denominations list is sorted from highest to lowest 4 | # uses python2.7 5 | 6 | # submitted by https://github.com/stroy1 7 | def get_combinations(amount, denominations): 8 | total = 0 9 | 10 | copy_denominations = deepcopy(denominations) 11 | for value in denominations: 12 | 13 | remainder = amount - value 14 | 15 | if remainder == 0: 16 | total += 1 17 | 18 | elif remainder > 0: 19 | total += get_combinations(remainder, copy_denominations) 20 | 21 | copy_denominations.pop(0) 22 | 23 | return total 24 | 25 | 26 | print "get_combinations(4, [3, 2, 1]): ", get_combinations(4, [3, 2, 1]) 27 | print "get_combinations(10, [5, 2, 1]): ", get_combinations(10, [5, 2, 1]) 28 | -------------------------------------------------------------------------------- /challenges/coinDenominations/solutions/coinDenominations2.py: -------------------------------------------------------------------------------- 1 | 2 | def coin_combos (amount, coins): 3 | # assert that coins is a list and amount is an integer 4 | assert isinstance(coins, list) 5 | assert isinstance(amount, int) 6 | # sort the coins in reverse order 7 | coins = sorted(coins, reverse = True) 8 | # base cases 9 | if amount < 0 or len(coins) == 0: 10 | return 0 11 | if amount == 0: 12 | return 1 13 | # recurse until base cases are reached 14 | return coin_combos(amount - coins[0], coins) + coin_combos(amount, coins[1:]) 15 | 16 | 17 | coin_combos(8, [4, 2, 1]) # should output 9 18 | 19 | ## submitted by https://github.com/emschuch 20 | -------------------------------------------------------------------------------- /challenges/containsDuplicate/containsDuplicate.md: -------------------------------------------------------------------------------- 1 | ### Contains Duplicate 2 | 3 | Given an array of integers, find if the array contains any duplicates. 4 | Your function should return true if any value appears at least twice in the array, 5 | and it should return false if every element is distinct. 6 | -------------------------------------------------------------------------------- /challenges/containsDuplicate/solutions/containsDuplicate.py: -------------------------------------------------------------------------------- 1 | def containsDuplicate(nums): 2 | return not len(set(nums)) == len(nums) 3 | 4 | if __name__ == "__main__": 5 | print(containsDuplicate([33,3,1,33,133])) 6 | -------------------------------------------------------------------------------- /challenges/convertTime/ConvertTime.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Submitting a java version of the solution 3 | **/ 4 | public class ConvertTime{ 5 | public static String convertTime(int value){ 6 | //this is to handle negative integers. 7 | boolean isNegative = (value < 0); 8 | 9 | //Convert to the absolute postive number and use that value instead. So you do not end up with a negative sign in both the minute and hour string 10 | value = Math.abs(value); 11 | 12 | //calculate for hours 13 | int hours = value/60; 14 | 15 | //remainder would be minutes 16 | int mins = value % 60; 17 | 18 | // use the isNegative flag to determine whether to put a negative sign before the final string or not; 19 | return (isNegative? "-": "") + hours + ":" + mins; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /challenges/convertTime/convertTime.md: -------------------------------------------------------------------------------- 1 | # Convert time 2 | 3 | ## Problem 4 | Write a function that takes a number of minutes and returns a string containing number of hours and the numbers of minutes that 5 | parameter converts to, separated by a colon. 6 | 7 | ## Example 8 | ```javascript 9 | f(126) 10 | // => "2:6" 11 | f(45) 12 | // => "0:45" 13 | ``` 14 | 15 | [Source](https://www.coderbyte.com/editor/guest:Time%20Convert:JavaScript) 16 | -------------------------------------------------------------------------------- /challenges/creditCardMask/ccMask.md: -------------------------------------------------------------------------------- 1 | ## Credit Card Mask 2 | 3 | Usually when you buy something, you're asked whether your credit card number, phone number or answer to your most secret question is still correct. However, since someone could look over your shoulder, you don't want that shown on your screen. Instead, we mask it. 4 | 5 | Your task is to write a function maskify, which changes all but the last four characters into '#'. 6 | #### Example: 7 | ``` 8 | maskify("4556364607935616") == "############5616" 9 | maskify( "1") == "1" 10 | maskify( "") == "" 11 | // "What was the name of your first pet?" 12 | 13 | maskify("Skippy") == "##ippy" 14 | ``` 15 | 16 | 17 | Source: [CodeWars](http://www.codewars.com/kata/credit-card-mask/javascript) 18 | 19 | submitted by [Kate Shishkina](https://github.com/shishkina) 20 | -------------------------------------------------------------------------------- /challenges/creditCardMask/solutions/ccMask.js: -------------------------------------------------------------------------------- 1 | // Using RegEx: 2 | 3 | function maskify(cc) { 4 | return cc.slice(0, -4).replace(/./g, '#') + cc.slice(-4); 5 | } 6 | 7 | maskify("Skippy"); 8 | maskify("13243567897065"); 9 | -------------------------------------------------------------------------------- /challenges/creditCardMask/solutions/cc_mask.rb: -------------------------------------------------------------------------------- 1 | # O(1) time effi. 2 | def maskify(str: raise) 3 | return str if str.size <= 4 4 | "#{'#' * (str.size - 4)}#{str[-4..-1]}" 5 | end 6 | 7 | puts maskify(str:"4556364607935616") == "############5616" 8 | puts maskify(str: "1") == "1" 9 | puts maskify(str: "") == "" 10 | puts maskify(str: "Skippy") == "##ippy" -------------------------------------------------------------------------------- /challenges/creditCardMask/solutions/cc_mask_alt.js: -------------------------------------------------------------------------------- 1 | // return masked string 2 | function maskify(cc) { 3 | 4 | var maskedString = []; 5 | for (var i = 0; i < cc.length; i++){ 6 | if (i < cc.length - 4){ 7 | maskedString.push("#"); 8 | } else { 9 | maskedString.push(cc[i]) 10 | }; 11 | 12 | 13 | } 14 | 15 | maskedString = maskedString.join(""); 16 | return maskedString; 17 | } 18 | 19 | 20 | maskify("Skippy"); 21 | maskify("13243567897065"); 22 | -------------------------------------------------------------------------------- /challenges/creditCardMask/solutions/credit_card_mask_solution.rb: -------------------------------------------------------------------------------- 1 | def maskify(ccnum) 2 | ccnum = ccnum.to_s 3 | last_four = ccnum[-4..-1] 4 | length_to_obscure = ccnum.length - 4 5 | obscured = "" 6 | length_to_obscure.times { obscured << "#" } 7 | obscured += last_four 8 | end 9 | 10 | 11 | p maskify("4556364607935616") 12 | # "############5616" 13 | 14 | p maskify(4556364607935616) 15 | # "############5616" 16 | 17 | p maskify("Skippy") 18 | # "##ippy" 19 | -------------------------------------------------------------------------------- /challenges/cyclicalLinkedList/cyclicalLinkedList.md: -------------------------------------------------------------------------------- 1 | ## How could you determine if a [linked list](https://en.wikipedia.org/wiki/Linked_list) was circular or has a cycle? 2 | 3 | ``` 4 | x - x - x - x 5 | | | 6 | x - x 7 | ``` 8 | Bonus points for determining the length of the tail if it has one. 9 | -------------------------------------------------------------------------------- /challenges/cyclicalLinkedList/solutions/cyclicalLinkedList.js: -------------------------------------------------------------------------------- 1 | /* 2 | Assumes a node looks something like this: 3 | var nodeFoo = { 4 | next: function that returns nodeBar 5 | } 6 | 7 | */ 8 | 9 | function hasloop(startNode) { 10 | //create two pointers, a tortoise and a hare 11 | var tortoise = startNode.next(); 12 | var hare = tortoise.next(); 13 | //while there is somewhere to travel to along your linked list 14 | while(hare !== null) { 15 | //check if they are equal 16 | if(hare === tortoise) { 17 | //hare and tortoise have met: loop exists 18 | return true; 19 | } else { 20 | //travel to the each time 21 | var hare = hare.next().next(); 22 | var tortoise = tortoise.next(); 23 | } 24 | } 25 | //reached end of list no loop 26 | return false; 27 | } 28 | -------------------------------------------------------------------------------- /challenges/dictionary/dictionary.md: -------------------------------------------------------------------------------- 1 | **Level 5**
2 | Given an input string and a dictionary of words, split the input string into a space-separated sequence of dictionary words if possible. For example, if the input string is "thisisafunproblem" and the dictionary contains a standard set of English words,then we would return the string "this is a fun problem." 3 | 4 | submitted by [seemaullal](https://github.com/seemaullal) 5 | -------------------------------------------------------------------------------- /challenges/dictionary/solutions/dictionary.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | std::string GetSentence(std::set& dictionary, std::string& words) { 6 | std::string check; 7 | std::string result; 8 | for (std::string::iterator it = words.begin(); it != words.end(); it++) { 9 | check += *it; 10 | if (dictionary.find(check)!=dictionary.end()) { 11 | result.append(check); 12 | result.append(" "); 13 | check = ""; 14 | } 15 | } 16 | if (!result.empty()) 17 | result.pop_back(); 18 | return result; 19 | } 20 | 21 | int main() 22 | { 23 | // example of dictionary 24 | std::set dictionary = {"this", "is", "a", "fun", "problem"}; 25 | std::string words; 26 | std::cout<<"Please, provide a string"<>words; 28 | std::string result = GetSentence(dictionary, words); 29 | std::cout< 1, 4 | 'an' => 1, 5 | 'fun' => 1, 6 | 'function' => 1, 7 | 'is' => 1, 8 | 'problem' => 1, 9 | 'this'=> 1 10 | } 11 | 12 | # O(N) N being the length of the string 13 | def space_separated(str: raise) 14 | first_index = 0 15 | last_index = 0 16 | results = [] 17 | 18 | str.size.times do 19 | check_string = str[first_index..last_index] 20 | if DICTIONARY[check_string] 21 | results << check_string 22 | first_index = last_index += 1 23 | last_index = first_index 24 | else 25 | last_index += 1 26 | end 27 | end 28 | 29 | puts results.join(" ") 30 | end 31 | 32 | space_separated(str: 'thisisafunproblem') #=> this is a fun problem 33 | 34 | # Potential Problem 35 | # This should output this is a function problem 36 | space_separated(str: 'thisisafunctionproblem') #=> this is a fun 37 | -------------------------------------------------------------------------------- /challenges/divisibleByBoth/divisibleByBoth.md: -------------------------------------------------------------------------------- 1 | # Divisible by both 2 | 3 | ## Problem 4 | Write a function that takes three arguments, and determines whether the first argument is 5 | divisible by both of the other two. Assume all inputs are positive integers. 6 | 7 | ## Example 8 | ```javascript 9 | f(100, 5, 4) 10 | // => true 11 | f(100, 5, 3) 12 | // => false 13 | f(10, 9, 8) 14 | // => false 15 | ``` 16 | 17 | [Source](https://www.codewars.com/kata/is-n-divisible-by-x-and-y/) 18 | -------------------------------------------------------------------------------- /challenges/double/double.md: -------------------------------------------------------------------------------- 1 | **Level 1**
2 | 3 | Create a function called double() that takes in an integer and returns that integer doubled. 4 | 5 | Example: double(2) should return 4 6 | 7 | Extension: If the input is not a number, return the string 'Not a number!' 8 | 9 | 10 | Submitted by [KamillaKhabibrakhmanova](https://github.com/KamillaKhabibrakhmanova) 11 | -------------------------------------------------------------------------------- /challenges/double/solutions/double.py: -------------------------------------------------------------------------------- 1 | ### Here i only checked if the number is integer. 2 | ### for the case of checking other numeric types: 3 | ### isinstance(number, (int, float, long,...) 4 | 5 | def double(number): 6 | if isinstance(number, int): 7 | return number*2 8 | else: 9 | print ("Not a number!") 10 | #print double(19) 11 | #print double("fr") 12 | 13 | ## submitted by [jungjung917](https://github.com/jungjung917) 14 | -------------------------------------------------------------------------------- /challenges/double/solutions/javascript.js: -------------------------------------------------------------------------------- 1 | var double = function(n) { 2 | var answer = n + n; 3 | return answer; 4 | } 5 | 6 | // Submitted by [KamillaKhabibrakhmanova](https://github.com/KamillaKhabibrakhmanova) 7 | -------------------------------------------------------------------------------- /challenges/double/solutions/pseudocode.md: -------------------------------------------------------------------------------- 1 | ``` 2 | function double(num) 3 | var answer 4 | answer = num + num 5 | return answer 6 | ``` 7 | 8 | Submitted by [KamillaKhabibrakhmanova](https://github.com/KamillaKhabibrakhmanova) 9 | -------------------------------------------------------------------------------- /challenges/double/solutions/ruby.rb: -------------------------------------------------------------------------------- 1 | =begin 2 | 3 | INPUT EXAMPLES OUTPUT EXAMPLES 4 | 1. 2 4 5 | 2. '2' 'Not a number!' 6 | 3. "str" 'Not a number!' 7 | 4. 100,000 'Not a number!' 8 | 9 | 10 | 11 | PROCESS 12 | 1. Validate is_a? integer 13 | 2. 'Not a number!' if != integer and return 14 | 3. Multiply number * 2 15 | =end 16 | 17 | #ANSWER 18 | def double(num) 19 | return 'Not a number!' unless num.is_a? Integer 20 | num * 2 21 | end 22 | 23 | 24 | #TESTING 25 | problems = [ 26 | [2 , 4], 27 | ['2' , 'Not a number!'], 28 | [ "str", 'Not a number!'], 29 | [ nil, 'Not a number!'], 30 | ['100,000', 'Not a number!'] 31 | ] 32 | 33 | problems.each do |problem| 34 | if double(problem[0]) == problem[1] 35 | puts 'Correct!' 36 | else 37 | puts 'Wrong' 38 | end 39 | end 40 | 41 | #submitted by [Dushyanthi Pierish](https://github.com/dushi27) 42 | -------------------------------------------------------------------------------- /challenges/eggBoiler/eggBoiler.md: -------------------------------------------------------------------------------- 1 | ## Egg boiler 2 | Problem originally found on [codewars](http://www.codewars.com/) 3 | 4 | Imagine you run a restaurant, where the main specialty is a boiled egg. Your particular pot/stove set up allows you to boil up to 8 eggs every 5 minutes. If all of the attendees from tonight's meet up went to your restaurant at once after some awesome algorithm-ing, how could you determine how long it would take before the last person got their egg? 5 | -------------------------------------------------------------------------------- /challenges/eggBoiler/solutions/Solution1.js: -------------------------------------------------------------------------------- 1 | // javascript solution 2 | 3 | function cookingTime(eggs) { 4 | var time = 0; 5 | while (eggs > 0) { 6 | time += 5; 7 | eggs -= 8; 8 | } 9 | return time; 10 | } 11 | 12 | // javascript tests 13 | 14 | console.log(cookingTime(0) === 0 ); 15 | 16 | console.log(cookingTime(5) === 0 ); 17 | 18 | console.log(cookingTime(10) === 10); 19 | -------------------------------------------------------------------------------- /challenges/eggBoiler/solutions/Solution1.py: -------------------------------------------------------------------------------- 1 | import math 2 | def find_time(num_people): 3 | num_mins = math.ceil(num_people/8.0) * 5 4 | return num_mins 5 | 6 | #print find_time(1) 7 | #print find_time(8) 8 | #print find_time(10) 9 | 10 | ## submitted by [jungjung917](https://github.com/jungjung917) 11 | -------------------------------------------------------------------------------- /challenges/evenOddLetters/evenOddLetters.md: -------------------------------------------------------------------------------- 1 | Easy mode: Check if the number of letters in a word are even or odd. 2 | 3 | Medium mode: Check if the number of unique letters in a word are even or odd. For example, "llama" has 3 unique letters, which is odd. 4 | 5 | [source](http://golf.shinh.org/p.rb?different+letters+parity) 6 | -------------------------------------------------------------------------------- /challenges/evenOddLetters/solutions/evenOddLetters.py: -------------------------------------------------------------------------------- 1 | # Author is github id: ddk376 2 | # Contributors : Python group in the January 17, 2017 meetup 3 | # Version: Python 3.5.2 4 | 5 | def evenOddLetters(s, unique = False ): 6 | """Takes a string and checks the number of letter in a word are even or odd. 7 | If unique is set to True, it checks the number of unique letters in a word are even or odd""" 8 | 9 | if unique: s = set(s) 10 | if len(s) % 2 == 0: 11 | print("Even") 12 | else: 13 | print("Odd") 14 | 15 | if __name__ == "__main__": 16 | print("Testing evenOddLetters............................") 17 | evenOddLetters("llama") 18 | evenOddLetters("Hello world", unique = True) -------------------------------------------------------------------------------- /challenges/evenOddLetters/solutions/even_odd_letters.rb: -------------------------------------------------------------------------------- 1 | def even_odd_letters?(word: raise) 2 | raise ArgumentError unless !word.nil? 3 | letters = word.gsub(/\W+/, '') #extract letters from the word given 4 | 5 | # &1==0 binary test to check even/odd 6 | (letters.chars.uniq.size)&1==0 ? (p "#{word} has even number of unique letters") : (p "#{word} has odd unique letters") 7 | end 8 | 9 | even_odd_letters?(word: "w") #=> odd 10 | even_odd_letters?(word: "AA") #=> odd 11 | even_odd_letters?(word: "AAB") #=> even 12 | even_odd_letters?(word: "") #=> even (cz 0 is an even number) 13 | even_odd_letters?(word: nil) #=> ArgumentError -------------------------------------------------------------------------------- /challenges/factorial/factorial.md: -------------------------------------------------------------------------------- 1 | In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 5! = 5 x 4 x 3 x 2 x 1 = 120 2 | 3 | Write a program that can find the factorial of a number. Can you do it recursively? 4 | -------------------------------------------------------------------------------- /challenges/factorial/solutions/factorial.rb: -------------------------------------------------------------------------------- 1 | 2 | def factorial(n) 3 | (1..n).reduce(:*) 4 | end 5 | 6 | # factorial(5) results in 120 -------------------------------------------------------------------------------- /challenges/fibonacciChecker/fibonacciChecker.md: -------------------------------------------------------------------------------- 1 | # Fibonacci checker 2 | 3 | ## Problem 4 | Given a number, return a boolean indicating whether it's part of the Fibonacci sequence. 5 | 6 | ## Example 7 | ```javascript 8 | f(34) 9 | // => true 10 | f(35) 11 | // => false 12 | ``` 13 | 14 | [Source](https://www.coderbyte.com/editor/guest:Fibonacci%20Checker:JavaScript) 15 | -------------------------------------------------------------------------------- /challenges/fibonacciSum/fibonacci_sum.md: -------------------------------------------------------------------------------- 1 | Each new term in the Fibonacci sequence is generated by adding the previous two terms. 2 | By starting with 1 and 2, the first 10 terms will be: 3 | 4 | ``` 5 | 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... 6 | ``` 7 | 8 | By considering the terms in the Fibonacci sequence whose values do not exceed 9 | four million, find the sum of the even-valued terms. 10 | -------------------------------------------------------------------------------- /challenges/fibonacciSum/solutions/FibonacciSum.java: -------------------------------------------------------------------------------- 1 | /* 2 | To see output: 3 | 1) run `javac FibonacciSum.java` 4 | 2) run `java FibonacciSum 5 | */ 6 | 7 | public class FibonacciSum { 8 | 9 | int num; 10 | public FibonacciSum(int number){ 11 | this.num = number; 12 | } 13 | 14 | public int evenSum(){ 15 | int sum = 0, first = 0, second = 1; 16 | 17 | while (first + second < this.num){ 18 | int fibNum = first + second; 19 | 20 | if (fibNum % 2 == 0){ 21 | sum += fibNum; 22 | } 23 | 24 | first = second; 25 | second = fibNum; 26 | } 27 | 28 | return sum; 29 | } 30 | 31 | public static void main(String[] args){ 32 | FibonacciSum sumToHere = new FibonacciSum(4000000); 33 | int result = sumToHere.evenSum(); 34 | 35 | System.out.println(result); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /challenges/fibonacciSum/solutions/fibosum.js: -------------------------------------------------------------------------------- 1 | /* 2 | Explanation : instead of assigning and reassigning variables 'first', 'second', etc 3 | I used a js native array and implement it as a queue with initial values 1 and 2 (some may use classic 1,1) 4 | process.hrtime() is a Node environment time which returns tuplet array of [sec,nanosec] 5 | I wish I knew of a mathy way to get a better than O(n) runtime though! 6 | */ 7 | 8 | 9 | var arr = [1,2]; 10 | var accumulator = 0; 11 | var next= null; 12 | var result = (function(){ 13 | var start = process.hrtime(); 14 | while(arr[1]<4000000){ 15 | next = arr[0]+arr[1]; 16 | if (next%2===0){ 17 | accumulator+=next; 18 | } 19 | 20 | arr.push(next); 21 | arr.shift(); 22 | 23 | } 24 | var end = process.hrtime(); 25 | var runtime = [end[0]-start[0],end[1]-start[1] ]; 26 | return {acc: accumulator, time: runtime}; 27 | 28 | })(); 29 | console.log(result); 30 | -------------------------------------------------------------------------------- /challenges/fibonacciSum/solutions/ruby_fibonacci_sum.rb: -------------------------------------------------------------------------------- 1 | def fibonacci_sum 2 | fib_array = [1, 2] 3 | while fib_array.last < 4000000 4 | fib_array << fib_array[-1] + fib_array[-2] 5 | end 6 | fib_array.select{|num| num % 2 == 0}.inject(:+) 7 | end 8 | -------------------------------------------------------------------------------- /challenges/firstDuplicate/firstDuplicate.md: -------------------------------------------------------------------------------- 1 | # First Duplicate 2 | 3 | ## Problem 4 | Given an array a that contains only numbers in the range from 1 to a.length, find the first duplicate number for which 5 | the second occurrence has the minimal index. 6 | In other words, if there are more than 1 duplicated numbers, return the number for which the second occurrence has a 7 | smaller index than the second occurrence of the other number does. If there are no such elements, return -1. 8 | 9 | ## Example 10 | For a = [2, 1, 3, 5, 3, 2], the output should be firstDuplicate(a) = 3. 11 | 12 | There are 2 duplicates: numbers 2 and 3. 13 | The second occurrence of 3 has a smaller index than the second occurrence of 2 does, so the answer is 3. 14 | 15 | For a = [2, 2], the output should be firstDuplicate(a) = 2; 16 | 17 | For a = [2, 4, 3, 5, 1], the output should be firstDuplicate(a) = -1. 18 | 19 | 20 | 21 | [Source](https://app.codesignal.com/interview-practice/task/pMvymcahZ8dY4g75q) 22 | -------------------------------------------------------------------------------- /challenges/firstMissingPositive/firstMissingPositive.md: -------------------------------------------------------------------------------- 1 | # First missing positive 2 | 3 | ## Problem 4 | Write a function that takes an unsorted array of integers and returns the 5 | smallest positive integer that is missing from the array. 6 | It should run in O(n) time. 7 | 8 | ## Examples 9 | ```javascript 10 | f([1, 2, 3]) 11 | // => 4 12 | 13 | f([3, -4, 17, 1]) 14 | // => 2 15 | 16 | f([99, 100, 101, 102]) 17 | // => 1 18 | ``` 19 | 20 | [Source](https://leetcode.com/problems/first-missing-positive/) 21 | -------------------------------------------------------------------------------- /challenges/fizzBuzz/fizzBuzz.md: -------------------------------------------------------------------------------- 1 | ##FizzBuzz 2 | 3 | Write a program that prints the integers from 1 to 100. 4 | But for multiples of three print "Fizz" instead of the number, and for the multiples of five print "Buzz". 5 | For numbers which are multiples of both three and five print "FizzBuzz". 6 | 7 | ## Source 8 | As seen in many many places, but this time was borrowed from here: http://rosettacode.org/wiki/FizzBuzz 9 | 10 | submitted by [seemaullal](https://github.com/seemaullal) 11 | -------------------------------------------------------------------------------- /challenges/fizzBuzz/solutions/fizzBuzz.js: -------------------------------------------------------------------------------- 1 | var fizzBuzz = function () { 2 | var i, output; 3 | for (i = 1; i < 101; i += 1) { 4 | output = ''; 5 | if (!(i % 3)) { output += 'Fizz'; } 6 | if (!(i % 5)) { output += 'Buzz'; } 7 | console.log(output || i);//empty string is false, so we short-circuit 8 | } 9 | }; 10 | 11 | //from http://rosettacode.org/wiki/FizzBuzz#JavaScript 12 | -------------------------------------------------------------------------------- /challenges/fizzBuzz/solutions/fizzBuzz.py: -------------------------------------------------------------------------------- 1 | def FizzBuzz(): 2 | for i in range(1,101): 3 | if (i % 3 == 0): 4 | if(i % 5 == 0 ): 5 | print "FizzBuzz" 6 | else: 7 | print "Fizz" 8 | else: 9 | if(i % 5 == 0): 10 | print "Buzz" 11 | 12 | FizzBuzz() 13 | 14 | ## submitted by [jungjung917](https://github.com/jungjung917) 15 | -------------------------------------------------------------------------------- /challenges/fizzBuzz/solutions/fizzBuzz.rb: -------------------------------------------------------------------------------- 1 | def fizzBuzz() 2 | for i in 1...100 3 | if (i % 3 == 0 && i % 5 == 0) 4 | puts "FizzBuzz" 5 | elsif (i % 3 == 0) 6 | puts "Fizz" 7 | elsif (i % 5 == 0) 8 | puts "Buzz" 9 | else 10 | puts i 11 | end 12 | end 13 | end 14 | 15 | fizzBuzz() -------------------------------------------------------------------------------- /challenges/fizzBuzz/solutions/fizzBuzz_2nd.py: -------------------------------------------------------------------------------- 1 | def Fizzbuzz(): 2 | for i in range(1,101): print("Buzz"*(i%3==0) + "Fizz"*(i%5==0) or i) 3 | Fizzbuzz() 4 | 5 | ## submitted by [jungjung917](https://github.com/jungjung917) 6 | -------------------------------------------------------------------------------- /challenges/gcd/gcd.md: -------------------------------------------------------------------------------- 1 | Write a program to find the greatest common divisor (gcd) of two positive numbers. Can you do so recursively? Iteratively? 2 | -------------------------------------------------------------------------------- /challenges/getFileExtension/getFileExtension.md: -------------------------------------------------------------------------------- 1 | **Level 2**
2 | 3 | Create a function called getFileExtension that returns the extension of a file name. If the inputed string does not have an extension, return false. 4 | 5 | Example: getFileExtension('resume.pdf') should return 'pdf'. 6 | 7 | Submitted by [KamillaKhabibrakhmanova](https://github.com/KamillaKhabibrakhmanova) 8 | -------------------------------------------------------------------------------- /challenges/getFileExtension/solutions/getFileExtension.py: -------------------------------------------------------------------------------- 1 | ##Level 2 2 | """Create a function called getFileExtension that returns the extension of a file name. 3 | If the inputed string does not have an extension, return false. 4 | Example: getFileExtension('resume.pdf') should return 'pdf'.""" 5 | 6 | def getFileExtension(filename): 7 | Filesplit = filename.rsplit('.',1) 8 | print Filesplit 9 | if (len(Filesplit) > 1) : 10 | return Filesplit[len(Filesplit)-1] 11 | else: 12 | return False 13 | 14 | #print getFileExtension("my.resume.updated.pdf") 15 | #print getFileExtension("resume") 16 | 17 | ## submitted by [jungjung917](https://github.com/jungjung917) 18 | -------------------------------------------------------------------------------- /challenges/getFileExtension/solutions/pseudocode.md: -------------------------------------------------------------------------------- 1 | ``` 2 | function getFileExtension(string) 3 | var answer 4 | search string('.') 5 | if search returns nothing: 6 | return false 7 | else: 8 | answer = everything after the dot 9 | return answer 10 | ``` 11 | 12 | // Submitted by [KamillaKhabibrakhmanova](https://github.com/KamillaKhabibrakhmanova) 13 | -------------------------------------------------------------------------------- /challenges/getFileExtension/solutions/ruby.rb: -------------------------------------------------------------------------------- 1 | =begin 2 | 3 | INPUT, OUTPUT 4 | ['resume.pdf' , 'pdf'], 5 | ['re_sume...pdf' , 'pdf'], 6 | ['resu.me.gif' , 'gif'], 7 | ['resu342me' , false], 8 | ["'r'*26", false] 9 | 10 | OPTIONS 11 | 1. split the string by . and get the last element if array.length > 1 12 | -> Con have to create a new element 13 | 2. search for the last '.' in the string and extract the file extention 14 | 15 | =end 16 | 17 | #ANSWER 18 | def getFileExtension(doc) 19 | data = doc.split('.') 20 | data.length > 1 ? data.last: false 21 | end 22 | 23 | #TEST 24 | questions = [ 25 | ['resume.pdf' , 'pdf'], 26 | ['re_sume...pdf' , 'pdf'], 27 | ['resu.me.gif' , 'gif'], 28 | ['resu342me' , false], 29 | ["#{'r'*260}.pdf" , 'pdf'] 30 | ] 31 | 32 | questions.each do |q| 33 | getFileExtension(q[0]) == q[1] ? (puts 'Correct!'): (puts 'Wrong') 34 | end 35 | 36 | #submitted by [Dushyanthi Pierish](https://github.com/dushi27) 37 | -------------------------------------------------------------------------------- /challenges/getMin/getMin.md: -------------------------------------------------------------------------------- 1 | **Level 3**
2 | Design a stack that support the normal stack operations( `push()`, `pop()`, `peek()`, and `isEmpty()` ) but also has a function called `getMin()` which returns the value of the minimum element in the stack. All functions should run in constant ( (O(1) ) time. 3 | 4 | submitted by [seemaullal](https://github.com/seemaullal) 5 | -------------------------------------------------------------------------------- /challenges/groupAnagrams/groupAnagrams.md: -------------------------------------------------------------------------------- 1 | ## Group anagrams 2 | 3 | ## Problem 4 | 5 | Given an array of strings, group anagrams together. 6 | Output is an array of groups, which are themselves arrays. 7 | 8 | ## Example 9 | 10 | Input: ["eat", "tea", "tan", "ate", "nat", "bat"] 11 | 12 | Output: 13 | 14 | [ 15 | 16 | ["ate", "eat", "tea"], 17 | 18 | ["nat", "tan"], 19 | 20 | ["bat"] 21 | 22 | ] 23 | 24 | [Source](https://leetcode.com/problems/group-anagrams/) 25 | -------------------------------------------------------------------------------- /challenges/hammingDistancev2/hammingDistance.md: -------------------------------------------------------------------------------- 1 | # Hamming Distance 2 | 3 | ## Problem 4 | 5 | The Hamming distance between two integers is the number of positions at which the corresponding bits are different. 6 | 7 | Given two integers x and y, calculate the Hamming distance. 8 | 9 | Note: 10 | 0 ≤ x, y < 2^31. 11 | 12 | ## Example: 13 | ``` 14 | Input: x = 1, y = 4 15 | 16 | Output: 2 17 | 18 | Explanation: 19 | 1 (0 0 0 1) 20 | 4 (0 1 0 0) 21 | ↑ ↑ 22 | ``` 23 | 24 | The above arrows point to positions where the corresponding bits are different. 25 | 26 | 27 | [Source](https://leetcode.com/problems/hamming-distance/) 28 | -------------------------------------------------------------------------------- /challenges/houseRobber/houseRobber.md: -------------------------------------------------------------------------------- 1 | # houseRobber 2 | 3 | ## Problem 4 | 5 | You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night. 6 | 7 | Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police. 8 | 9 | ## Examples 10 | 11 | ``` 12 | Input: [1,2,3,1] 13 | 14 | Output: 4 15 | 16 | Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3). Total amount you can rob = 1 + 3 = 4. 17 | 18 | Input: [2,7,9,3,1] 19 | 20 | Output: 12 21 | 22 | Explanation: Rob house 1 (money = 2), rob house 3 (money = 9) and rob house 5 (money = 1). Total amount you can rob = 2 + 9 + 1 = 12. 23 | ``` 24 | 25 | [Source](https://leetcode.com/problems/house-robber/) 26 | -------------------------------------------------------------------------------- /challenges/houseRobber/solutions/houseRobber.cpp: -------------------------------------------------------------------------------- 1 | // Please checkout link for explanation: 2 | // https://leetcode.com/problems/house-robber/discuss/156523/From-good-to-great.-How-to-approach-most-of-DP-problems. 3 | 4 | int rob(vector& nums) { 5 | if (nums.size() == 0) 6 | return 0; 7 | 8 | int f1 = 0; 9 | int curr = 0; // holds maxProfit 10 | 11 | for (int num : nums) { 12 | int f2 = f1; // f2 is f[k-2] 13 | f1 = curr; // f1 is f[k-1] 14 | 15 | // plug into formula above 16 | curr = max(f2 + num, f1); 17 | } 18 | 19 | return curr; 20 | } 21 | -------------------------------------------------------------------------------- /challenges/houseRobber/solutions/houseRobber.java: -------------------------------------------------------------------------------- 1 | // Please checkout link for explanation: 2 | // https://leetcode.com/problems/house-robber/discuss/55681/Java-O(n)-solution-space-O(1) 3 | 4 | public int rob(int[] num) { 5 | int prevNo = 0; 6 | int prevYes = 0; 7 | for (int n : num) { 8 | int temp = prevNo; 9 | prevNo = Math.max(prevNo, prevYes); 10 | prevYes = n + temp; 11 | } 12 | return Math.max(prevNo, prevYes); 13 | } -------------------------------------------------------------------------------- /challenges/houseRobber/solutions/houseRobber.js: -------------------------------------------------------------------------------- 1 | // Please checkout link for explanation: 2 | // https://leetcode.com/problems/house-robber/discuss/167616/javascript-clean-DP-solution 3 | 4 | var rob = function(nums) { 5 | if(nums.length === 0) return 0; 6 | if(nums.length === 1) return nums[0]; 7 | let totals = [nums[0], Math.max(nums[0], nums[1])]; 8 | for(let i = 2; i < nums.length; i ++){ 9 | totals[i] = Math.max(totals[i - 1], totals[i - 2] + nums[i]); 10 | } 11 | return totals[totals.length - 1]; 12 | }; -------------------------------------------------------------------------------- /challenges/houseRobber/solutions/houseRobber.py: -------------------------------------------------------------------------------- 1 | # Please checkout link for explanation: 2 | # https://leetcode.com/problems/house-robber/discuss/55696/Python-solution-3-lines. 3 | 4 | # f(0) = nums[0] 5 | # f(1) = max(num[0], num[1]) 6 | # f(k) = max( f(k-2) + nums[k], f(k-1) ) 7 | def rob(self, nums): 8 | last, now = 0, 0 9 | 10 | for i in nums: last, now = now, max(last + i, now) 11 | 12 | return now -------------------------------------------------------------------------------- /challenges/iBeforeEExceptAfterC/iBeforeEExceptAfterC.md: -------------------------------------------------------------------------------- 1 | # I before E except after C 2 | 3 | ## Problem 4 | 5 | The phrase `"I before E, except after C"` is a widely known mnemonic which is supposed to help when spelling English words. 6 | 7 | 8 | Task 9 | Using the word list from http://wiki.puzzlers.org/pub/wordlists/unixdict.txt, 10 | check if the two sub-clauses of the phrase are plausible individually: 11 | 12 | 1) "I before E when not preceded by C" 13 | 2) "E before I when preceded by C" 14 | 15 | If both sub-phrases are plausible then the original phrase can be said to be plausible. 16 | 17 | Something is plausible if **the number of words having the feature is more than two times the number of words having the opposite feature** (where feature is 'ie' or 'ei' preceded or not by 'c' as appropriate). 18 | 19 | (I know, I know, it also goes "and when sounding like A as in neighbor or weigh"! But that's too hard 😂) 20 | 21 | [Source](http://rosettacode.org/wiki/I_before_E_except_after_C) 22 | -------------------------------------------------------------------------------- /challenges/insertionSort/insertionSort.md: -------------------------------------------------------------------------------- 1 | # Implement Insertion Sort 2 | 3 | What is Insertion Sort? 4 | ``` 5 | Insertion sort iterates, consuming one input element each repetition, 6 | and growing a sorted output list. 7 | Each iteration, insertion sort removes one element from the input data, 8 | finds the location it belongs within the sorted list, and inserts it there. 9 | It repeats until no input elements remain. 10 | ``` 11 | -https://en.wikipedia.org/wiki/Insertion_sort 12 | 13 | Can you show an example? 14 | ``` 15 | Example: The following table shows the steps for sorting the sequence {3, 7, 4, 9, 5, 2, 6, 1}. 16 | In each step, the key under consideration is underlined. 17 | The key that was moved (or left in place because it was biggest yet considered) 18 | in the previous step is shown in bold. 19 | 20 | 3 7 4 9 5 2 6 1 21 | 22 | 3 7 4 9 5 2 6 1 23 | 24 | 3 7 4 9 5 2 6 1 25 | 26 | 3 4 7 9 5 2 6 1 27 | 28 | 3 4 7 9 5 2 6 1 29 | 30 | 3 4 5 7 9 2 6 1 31 | 32 | 2 3 4 5 7 9 6 1 33 | 34 | 2 3 4 5 6 7 9 1 35 | 36 | 1 2 3 4 5 6 7 9 37 | ``` 38 | -https://en.wikipedia.org/wiki/Insertion_sort 39 | -------------------------------------------------------------------------------- /challenges/interleavingString/interleavingString.md: -------------------------------------------------------------------------------- 1 | ## LeetCode - Hard. Reverse Integer 2 | ## Problem 3 | Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. 4 | 5 | ## Example 1 6 | ``` 7 | Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac" 8 | Output: true 9 | ``` 10 | 11 | ## Example 2 12 | ``` 13 | Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc" 14 | Output: false 15 | 16 | ``` 17 | [Source](https://leetcode.com/problems/interleaving-string/) 18 | 19 | -------------------------------------------------------------------------------- /challenges/investment/investment.md: -------------------------------------------------------------------------------- 1 | Write a recursive method that takes as parameters an initial investment amount, an annual interest rate, and a number of years. The method should return the value of the investment after the given number of years, assuming that the interest is compounded annually. (For example, if the initial investment is 1000 and the interest rate is 10 percent, then after one year the investment will be worth 1100, after two years 1210, after three years 1331, etc.) 2 | 3 | found: http://www.cs.wustl.edu/~kjg/cse131/modules/recursion/lab.html 4 | -------------------------------------------------------------------------------- /challenges/investment/solutions/investment.js: -------------------------------------------------------------------------------- 1 | //assumes that all inputs are ints including interest (e.g. 10 instead of 0.10) 2 | 3 | let invest = (value, interest, yrs) => { 4 | 5 | if (yrs <= 0) { 6 | return value; 7 | } 8 | 9 | value += (value * (interest / 100)); 10 | yrs--; 11 | 12 | return invest(value, interest, yrs); 13 | } 14 | 15 | console.log(invest(1000, 10, 2)); //1210 16 | -------------------------------------------------------------------------------- /challenges/investment/solutions/investment.rb: -------------------------------------------------------------------------------- 1 | def value_of_the_investment(investment: raise, rate: raise, num_years: raise) 2 | # assumes the rate is given as a percent decimal 3 | num_years.times do |yr| 4 | investment = (investment * rate) + investment 5 | end 6 | investment 7 | end 8 | 9 | puts "$1000 at 10% for 3 years will yeild #{value_of_the_investment(investment: 1000, rate: 0.10, num_years: 3)}" -------------------------------------------------------------------------------- /challenges/isTreeSymmetric/solutions/isTreeSymmetric.py: -------------------------------------------------------------------------------- 1 | def isTreeSymmetric(root): 2 | if not root: return True 3 | 4 | def sym(left, right): 5 | if not left and not right: 6 | return True 7 | if not left or not right: 8 | return False 9 | return left.val == right.val and sym(left.left, right.right) and sym(left.right, right.left) 10 | 11 | return sym(root.left, root.right) 12 | -------------------------------------------------------------------------------- /challenges/kthToLastElement/kthToLastElement.md: -------------------------------------------------------------------------------- 1 | ## Find the kth to last element of a linked list 2 | Problem found on [Growing with the Web](http://www.growingwiththeweb.com/2015/08/find-the-kth-last-element-in-a-linked-list.html) 3 | 4 | Find the kth to last element of a singly linked list. 5 | 6 | submitted by [lei-clearsky](https://github.com/lei-clearsky) 7 | -------------------------------------------------------------------------------- /challenges/largestPalindromicNumber/largest_palindromic_number.md: -------------------------------------------------------------------------------- 1 | A palindromic number reads the same both ways. 2 | The largest palindrome made from the product of two 2-digit numbers 3 | is 9009 = 91 × 99. 4 | 5 | Find the largest palindrome made from the product of two 3-digit numbers. 6 | -------------------------------------------------------------------------------- /challenges/largestPalindromicNumber/solutions/ruby_largest_palindromic_num.rb: -------------------------------------------------------------------------------- 1 | def factors(array) 2 | array.combination(2).to_a.map{|set| set.inject(:*)} 3 | end 4 | 5 | def palindromes 6 | (998001.downto(10000)).to_a.select{|x| x == x.to_s.reverse.to_i} 7 | end 8 | 9 | def palindromic 10 | palindrome = [] 11 | palindromes.each do |item| 12 | factor_array = (999.downto(100)).to_a.select{|x| item % x == 0} 13 | palindrome << item if factors(factor_array).include?(item) 14 | break if palindrome.length == 1 15 | end 16 | palindrome[0] 17 | end 18 | -------------------------------------------------------------------------------- /challenges/largestPrime/largest_prime.md: -------------------------------------------------------------------------------- 1 | The prime factors of 13195 are 5, 7, 13 and 29. 2 | What is the largest prime factor of the number 600851475143 ? 3 | -------------------------------------------------------------------------------- /challenges/largestPrime/solutions/ruby_largest_prime.rb: -------------------------------------------------------------------------------- 1 | def helper(num) 2 | prime = true 3 | (2...num).each{|x| 4 | prime = false if num % x == 0 5 | break if prime == false 6 | } 7 | prime 8 | end 9 | 10 | def largest_prime_factor(number) 11 | x = 2 12 | prime = [] 13 | product = 1 14 | while product < number 15 | if ((number % x == 0) && (helper(x) == true)) 16 | prime << x 17 | product *= x 18 | end 19 | x += 1 20 | end 21 | prime.last 22 | end 23 | -------------------------------------------------------------------------------- /challenges/latticePaths/latticePaths.md: -------------------------------------------------------------------------------- 1 | ###The problem 2 | 3 | Given a square grid, how could you determine the number of possible paths from the top left of the grid to the bottom right, assuming you can only move to the right and down? 4 | 5 | ###Example 6 | 7 | ![Example](https://projecteuler.net/project/images/p015.gif) 8 | There are 6 paths to the bottom in a 2 by 2 grid 9 | 10 | ###Source 11 | 12 | [Source](https://projecteuler.net/problem=15) 13 | -------------------------------------------------------------------------------- /challenges/latticePaths/solutions/LatticePaths.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WomenWhoCodeNYC/Algorithms/69bd06b806826392b7d0d675fe6f9966d592f48c/challenges/latticePaths/solutions/LatticePaths.java -------------------------------------------------------------------------------- /challenges/latticePaths/solutions/latticePaths.js: -------------------------------------------------------------------------------- 1 | var paths = {}; 2 | function memoizer(x, y, max){ 3 | if(paths[[x,y,max]]){ 4 | return paths[[x,y,max]]; 5 | } 6 | else{ 7 | return paths[[x,y,max]] = paths2Bottom(x, y, max); 8 | } 9 | } 10 | function paths2Bottom(x, y, max){ 11 | if (x == max || y == max){ 12 | return 1; 13 | } 14 | return memoizer(x+1, y, max) + memoizer(x, y+1, max); 15 | } 16 | paths2Bottom(0,0,20); 17 | -------------------------------------------------------------------------------- /challenges/leadersInArray/leadersInArray.md: -------------------------------------------------------------------------------- 1 | # Leaders in array 2 | 3 | ## Problem 4 | 5 | Write a program to print all the leaders in the array. 6 | An element is a leader if it is greater than all the elements to its right. 7 | (The rightmost element is always a leader.) 8 | 9 | ## Example 10 | 11 | In the array {16, 17, 4, 3, 5, 2}, the leaders are 17, 5 and 2. 12 | 13 | [Source](https://www.geeksforgeeks.org/leaders-in-an-array/) 14 | -------------------------------------------------------------------------------- /challenges/lemonadeChange/solutions/lemonadeChange.java: -------------------------------------------------------------------------------- 1 | // Please checkout link for explanation: 2 | // https://leetcode.com/problems/lemonade-change/discuss/143719/C%2B%2BJavaPython-Straight-Forward 3 | 4 | public boolean lemonadeChange(int[] bills) { 5 | int five = 0, ten = 0; 6 | for (int i : bills) { 7 | if (i == 5) five++; 8 | else if (i == 10) {five--; ten++;} 9 | else if (ten > 0) {ten--; five--;} 10 | else five -= 3; 11 | if (five < 0) return false; 12 | } 13 | return true; 14 | } -------------------------------------------------------------------------------- /challenges/lemonadeChange/solutions/lemonadeChange.py: -------------------------------------------------------------------------------- 1 | # Please checkout link for explanation: 2 | # https://leetcode.com/problems/lemonade-change/discuss/143719/C%2B%2BJavaPython-Straight-Forward 3 | 4 | def lemonadeChange(self, bills): 5 | five = ten = 0 6 | for i in bills: 7 | if i == 5: five += 1 8 | elif i == 10: five, ten = five - 1, ten + 1 9 | elif ten > 0: five, ten = five - 1, ten - 1 10 | else: five -= 3 11 | if five < 0: return False 12 | return True -------------------------------------------------------------------------------- /challenges/letterCapitalize/letterCapitalize.md: -------------------------------------------------------------------------------- 1 | ## Letter Capitalize 2 | 3 | Write a function that takes a string and capitalizes the first letter of every word. Words will be separated by only one space. 4 | 5 | #### Example: 6 | 7 | ```javascript 8 | f("hello world") 9 | // "Hello World" 10 | 11 | f("101 Dalmatians is a great movie") 12 | // "101 Dalamatians Is A Great Movie" 13 | ``` 14 | 15 | Source: https://coderbyte.com/editor/guest:Letter%20Capitalize:JavaScript 16 | -------------------------------------------------------------------------------- /challenges/letterCapitalize/solutions/LetterCapitalize.java: -------------------------------------------------------------------------------- 1 | package solutions; 2 | 3 | public class LetterCapitalize { 4 | public static String capitalizeFirst(String str) { 5 | char[] chars = str.toCharArray(); 6 | 7 | for(int i = 0; i < chars.length; i++) { 8 | chars[i] = isWordStart(chars, i) ? Character.toUpperCase(chars[i]): chars[i]; 9 | } 10 | 11 | return new String(chars); 12 | } 13 | 14 | private static boolean isWordStart(char[] chars, int i) { 15 | return i == 0 || chars[i - 1] == ' '; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /challenges/letterCapitalize/testing/LetterCapitalizeTest.java: -------------------------------------------------------------------------------- 1 | package solutions; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | public class LetterCapitalizeTest { 8 | @Test 9 | public void test1() { 10 | String expected = "Hello World"; 11 | String actual = LetterCapitalize.capitalizeFirst("hello world"); 12 | assertEquals(expected, actual); 13 | } 14 | 15 | @Test 16 | public void test2() { 17 | String expected = "101 Dalmatians Is A Great Movie"; 18 | String actual = LetterCapitalize.capitalizeFirst("101 Dalmatians is a great movie"); 19 | assertEquals(expected, actual); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /challenges/letterTilePossibilities/letterTilePossibilities.md: -------------------------------------------------------------------------------- 1 | # Letter Tile Possibilities 2 | 3 | ## Problem 4 | 5 | You have a set of tiles, where each tile has one letter tiles[i] printed on it. 6 | Return the number of possible non-empty sequences of letters you can make. 7 | 8 | 9 | ## Example 1 : 10 | 11 | ``` 12 | Input: "AAB" 13 | Output: 8 14 | Explanation: The possible sequences are "A", "B", "AA", "AB", "BA", "AAB", "ABA", "BAA". 15 | 16 | ``` 17 | 18 | ## Example 2: 19 | 20 | ``` 21 | Input: "AAABBC" 22 | Output: 188 23 | ``` 24 | 25 | Note: 26 | 27 | 1 <= tiles.length <= 7 28 | tiles consists of uppercase English letters. 29 | 30 | 31 | [Source](https://leetcode.com/problems/letter-tile-possibilities/) 32 | -------------------------------------------------------------------------------- /challenges/longestCommonPrefix/longestCommonPrefix.md: -------------------------------------------------------------------------------- 1 | # Longest common prefix 2 | 3 | ## Problem 4 | Write a function that takes an array of strings as input and returns the longest common prefix string. 5 | Assume strings are all lowercase. 6 | 7 | If there is no common prefix, return an empty string. 8 | 9 | ## Examples 10 | ```javascript 11 | f(["hello", "helen", "hedgehog"]) 12 | // => "he" 13 | 14 | f(["dog", "fox", "outfox"]) 15 | // => "" 16 | ``` 17 | 18 | [Source](https://leetcode.com/problems/longest-common-prefix/) 19 | -------------------------------------------------------------------------------- /challenges/longestRange/longestRange.md: -------------------------------------------------------------------------------- 1 | **Level 4**
2 | Write a function that accepts as input an array of integers and then returns the length of the longest consecutive range of integers that appear somewhere in that array. For example, [16, 6, 12, 5, 4, 10, 2, 11, 13, 3, 15], it should return 5 (2,3,4,5,6 are all in the array so the longest range of consecutive numbers is 5). What if you wanted to actually return the numbers in the longest range (for example, for this example, you would return [2,3,4,5,6]). Analyze the time and space efficiency of your algorithm. 3 | 4 | submitted by [seemaullal](https://github.com/seemaullal) 5 | -------------------------------------------------------------------------------- /challenges/longestRange/solutions/LongestRange.java: -------------------------------------------------------------------------------- 1 | package solutions; 2 | 3 | import java.util.Arrays; 4 | 5 | public class LongestRange { 6 | public static int[] range(int[] ints) { 7 | int[] array = Arrays.copyOf(ints, ints.length + 1); 8 | array[ints.length] = Integer.MAX_VALUE; 9 | Arrays.sort(array); 10 | 11 | int currLongestLength = 1; 12 | int longestLength = 1; 13 | int longestLastIndex = 0; 14 | 15 | for (int i = 0; i < array.length - 1; i++) { 16 | if (array[i] != array[i + 1] - 1) { 17 | currLongestLength = 1; 18 | continue; 19 | } 20 | 21 | currLongestLength++; 22 | 23 | if (currLongestLength > longestLength) { 24 | longestLength = currLongestLength; 25 | longestLastIndex = i + 1; 26 | } 27 | } 28 | 29 | return range(array, longestLastIndex, longestLength); 30 | } 31 | 32 | public static int length(int[] ints) { 33 | return range(ints).length; 34 | } 35 | 36 | private static int[] range(int[] array, int last, int length) { 37 | int[] range = new int[length]; 38 | 39 | while(length > 0) { 40 | range[--length] = array[last--]; 41 | } 42 | 43 | return range; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /challenges/longestRange/testing/LongestRangeTest.java: -------------------------------------------------------------------------------- 1 | package solutions; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | public class LongestRangeTest { 8 | @Test 9 | public void testLength1() { 10 | int expected = 5; 11 | int actual = LongestRange.length(new int[] {16, 6, 12, 5, 4, 10, 2, 11, 13, 3, 15}); 12 | assertEquals(expected, actual); 13 | } 14 | 15 | @Test 16 | public void testRange1() { 17 | int[] expecteds = new int[]{2, 3, 4, 5, 6}; 18 | int[] actuals = LongestRange.range(new int[] {16, 6, 12, 5, 4, 10, 2, 11, 13, 3, 15}); 19 | assertArrayEquals(expecteds, actuals); 20 | } 21 | 22 | @Test 23 | public void testRange2() { 24 | int[] expecteds = new int[]{6, 7, 8, 9, 10}; 25 | int[] actuals = LongestRange.range(new int[] {1, 6, 0, 22, 4, 7, 9, 10, 8, 12}); 26 | assertArrayEquals(expecteds, actuals); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /challenges/majorityElement/majorityElement.md: -------------------------------------------------------------------------------- 1 | Problem 1 : Majority Element 2 | 3 | Given an array of size n, find the majority element. The majority element is the element that 4 | appears more than ⌊ n/2 ⌋ times. 5 | You may assume that the array is non-empty and the majority element always exist in the array. 6 | -------------------------------------------------------------------------------- /challenges/majorityElement/solutions/majorityElement.py: -------------------------------------------------------------------------------- 1 | def majorityElement(nums): 2 | nums.sort() #In place sorting 3 | return nums[len(nums)// 2] # Return middle element 4 | 5 | if __name__ == "__main__": 6 | print(majorityElement([5,4,11,3,199,11,11,11,11])) 7 | -------------------------------------------------------------------------------- /challenges/matchingClosingParenthesis/matchingClosingParenthesis.md: -------------------------------------------------------------------------------- 1 | ### Find the position(index) of the matching closing parenthesis on a given string. 2 | 3 | #### "Lorem ipsum (dolor sit amet, (consectetur adipiscing) elit, (sed do (eiusmod tempor incididunt) ut labore) et dolore magna) aliqua." 4 | 5 | #### For example: for the open parenthesis at position 12, the closing matching parenthesis is at position 122. 6 | 7 | #### For the open parenthesis at position 29, the closing matching parenthesis is at position 52. 8 | -------------------------------------------------------------------------------- /challenges/matchingClosingParenthesis/solutions/matching_closing_parenthesis.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Created on Fri Apr 20 12:53:44 2018 4 | 5 | @author: Elnaz Koopahi 6 | """ 7 | def matching_closing_parenthesis(s): 8 | l=[] 9 | for index in range(len(s)): 10 | if s[index]=='(': 11 | l.append(index) 12 | elif s[index]==')': 13 | try: 14 | print(l.pop(),',', index) 15 | except IndexError: 16 | print("Close parenthesis at", index, "does not match with any open paranthesis") 17 | 18 | while len(l): 19 | print("open parenthesis at", l.pop(), "does not match with any close paranthesis") 20 | 21 | 22 | def test_matching(): 23 | matching_closing_parenthesis("asdasdad") 24 | matching_closing_parenthesis("asdad(") 25 | matching_closing_parenthesis("adsad(asda)(asdadeh0())") 26 | matching_closing_parenthesis("") -------------------------------------------------------------------------------- /challenges/matchingClosingParenthesis/solutions/matching_closing_parenthesis.rb: -------------------------------------------------------------------------------- 1 | def matching_closing_parenthesis(str: raise) 2 | paranthesis_index = [] 3 | results = [] 4 | 5 | str.size.times do |i| 6 | if str[i] == "(" 7 | paranthesis_index << i 8 | elsif str[i] == ")" 9 | results << [paranthesis_index.pop, i] 10 | end 11 | end 12 | results 13 | end 14 | 15 | str = "Lorem ipsum (dolor sit amet, (consectetur adipiscing) elit, (sed do (eiusmod tempor incididunt) ut labore) et dolore magna) aliqua." 16 | p matching_closing_parenthesis(str: str) #=> [[29, 52], [68, 94], [60, 105], [12, 122]] -------------------------------------------------------------------------------- /challenges/maxConsecutiveOnes/maxConsecutiveOnes.md: -------------------------------------------------------------------------------- 1 | ### Max Consecutive Ones 2 | 3 | Given a binary array, find the maximum number of consecutive 1s in this array. 4 | 5 | Example 1: 6 | Input: [1,1,0,1,1,1] 7 | Output: 3 8 | Explanation: The first two digits or the last three digits are consecutive 1s. 9 | The maximum number of consecutive 1s is 3. 10 | Note: 11 | 12 | The input array will only contain 0 and 1. 13 | The length of input array is a positive integer and will not exceed 10,000 14 | -------------------------------------------------------------------------------- /challenges/maxConsecutiveOnes/solutions/maxConsecutiveOnes.py: -------------------------------------------------------------------------------- 1 | def maxConsecutiveOnes(arr): 2 | cnt = 0 3 | ans = 0 4 | for num in arr: 5 | if num == 1: 6 | cnt += 1 7 | ans = max(ans, cnt) 8 | else: 9 | cnt = 0 10 | return ans 11 | 12 | if __name__ == "__main__": 13 | print(maxConsecutiveOnes([5,101,14,1,1,1,13,1,1,45])) 14 | -------------------------------------------------------------------------------- /challenges/maximizeStockProfit/maximizeStockProfit.md: -------------------------------------------------------------------------------- 1 | # Maximize stock profit 2 | 3 | ## Problem 4 | Given a list of stock prices for a given day as an array of numbers, return the maximum profit that could have been made by buying a stock and then selling the stock later that day. If no profit could have been made, return -1. 5 | 6 | ## Example 7 | ```javascript 8 | f([45, 24, 35, 31, 40, 38, 11]) 9 | // => 16 10 | // the largest possible profit from this day is from buying the stock 11 | // at $24 and selling it at $40 to make $16 12 | ``` 13 | 14 | [Source](https://coderbyte.com/algorithm/stock-maximum-profit) 15 | -------------------------------------------------------------------------------- /challenges/maximumLengthofaConcatenatedStringwithUniqueCharacters/maximumLengthofaConcatenatedStringwithUniqueCharacters.md: -------------------------------------------------------------------------------- 1 | ## LeetCode - Medium. Maximum Length of a Concatenated String with Unique Characters 2 | ## Problem 3 | Given an array of strings arr. String s is a concatenation of a sub-sequence of arr which have unique characters. 4 | Return the maximum possible length of s. 5 | 6 | ## Example 1 7 | ``` 8 | Input: arr = ["un","iq","ue"] 9 | Output: 4 10 | Explanation: All possible concatenations are "","un","iq","ue","uniq" and "ique". 11 | Maximum length is 4. 12 | ``` 13 | 14 | ## Example 2 15 | ``` 16 | Input: arr = ["cha","r","act","ers"] 17 | Output: 6 18 | Explanation: Possible solutions are "chaers" and "acters". 19 | ``` 20 | 21 | ## Example 3 22 | ``` 23 | Input: arr = ["abcdefghijklmnopqrstuvwxyz"] 24 | Output: 26 25 | ``` 26 | ## Constraints: 27 | 28 | ``` 29 | 1 <= arr.length <= 16 30 | 1 <= arr[i].length <= 26 31 | arr[i] contains only lower case English letters. 32 | ``` 33 | 34 | [Source](https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters/) 35 | -------------------------------------------------------------------------------- /challenges/medianCollection/medianCollection.md: -------------------------------------------------------------------------------- 1 | Implement a class that calculates the median number in a group of numbers, allows you to add 2 | new numbers to a collection and can compute the median. 3 | 4 | e.g. 5 | class MedianCollection 6 | def add_number(number) 7 | // add nubmer to your collection 8 | end 9 | 10 | def median 11 | // return median 12 | end 13 | end 14 | 15 | What data structures you could use to store the numbers? 16 | How would your median calculation differ with each data structure? 17 | 18 | submitted by https://github.com/PaddyBadger 19 | -------------------------------------------------------------------------------- /challenges/medianCollection/solutions/medianCollection.rb: -------------------------------------------------------------------------------- 1 | # Upon instantiation, the class starts out with an empty array to store the collection of numbers 2 | 3 | class MedianCollection 4 | def initialize() 5 | @the_nums = [] 6 | @size = 0 7 | end 8 | 9 | def add(num) 10 | @the_nums << num 11 | @size += 1 12 | end 13 | 14 | def median 15 | @the_nums[(@size - 1)/2] 16 | end 17 | 18 | end 19 | 20 | # m = MedianCollection.new 21 | 22 | # m.add(4) 23 | # m.add(17) 24 | # m.add(19) 25 | # m.add(1) 26 | # m.add(12) 27 | # puts m.median -------------------------------------------------------------------------------- /challenges/medianMaintenance/medianMaintenance.md: -------------------------------------------------------------------------------- 1 | Found on [Algorithms: Design and Analysis, Part 1](https://www.coursera.org/course/algo) 2 | 3 | The goal of this problem is to implement the "Median Maintenance" algorithm (covered in the Week 5 lecture on heap applications). The text file contains a list of the integers from 1 to 10000 in unsorted order; you should treat this as a stream of numbers, arriving one by one. Letting xi denote the ith number of the file, the kth median mk is defined as the median of the numbers x1,…,xk. (So, if k is odd, then mk is ((k+1)/2)th smallest number among x1,…,xk; if k is even, then mk is the (k/2)th smallest number among x1,…,xk.) 4 | 5 | In the box below you should type the sum of these 10000 medians, modulo 10000 (i.e., only the last 4 digits). That is, you should compute (m1+m2+m3+⋯+m10000)mod10000. 6 | 7 | OPTIONAL EXERCISE: Compare the performance achieved by heap-based and search-tree-based implementations of the algorithm. -------------------------------------------------------------------------------- /challenges/mergeSort/mergeSort.md: -------------------------------------------------------------------------------- 1 | # Implement Merge Sort 2 | 3 | What is merge sort? 4 | ``` 5 | Conceptually, a merge sort works as follows: 6 | 7 | Divide the unsorted list into n sublists, 8 | each containing 1 element (a list of 1 element is considered sorted). 9 | Repeatedly merge sublists to produce new sorted 10 | sublists until there is only 1 sublist remaining. 11 | This will be the sorted list. 12 | ``` 13 | 14 | Can you show an example? 15 | 16 | ![image of merge sort](https://upload.wikimedia.org/wikipedia/commons/e/e6/Merge_sort_algorithm_diagram.svg) 17 | 18 | -https://en.wikipedia.org/wiki/Merge_sort 19 | -------------------------------------------------------------------------------- /challenges/mergeSortedLinkedLists/mergeSortedLinkedLists.md: -------------------------------------------------------------------------------- 1 | # Merge sorted linked lists 2 | 3 | ## Problem 4 | 5 | Merge _k_ sorted linked lists and return it as one sorted list. 6 | 7 | ## Example 8 | 9 | ``` 10 | Input: 11 | [ 12 | 1->4->5, 13 | 1->3->4, 14 | 2->6 15 | ] 16 | 17 | Output: 1->1->2->3->4->4->5->6 18 | ``` 19 | 20 | [Source](https://leetcode.com/problems/merge-k-sorted-lists/) 21 | -------------------------------------------------------------------------------- /challenges/minimumRotation/minimumRotation.md: -------------------------------------------------------------------------------- 1 | ### Minimum rotations required to get the same String 2 | 3 | Given a string, we need to find the minimum number of rotations required to get the same string. 4 | In this case, we will only consider Left rotations. 5 | 6 | Example: 7 | ``` 8 | Input : s = “geeks” 9 | Output : 5 10 | 11 | Input : s = “aaaa” 12 | Output :1 13 | ``` 14 | 15 | [Source](https://www.geeksforgeeks.org/minimum-rotations-required-to-get-the-same-string-set-2/) 16 | -------------------------------------------------------------------------------- /challenges/missingNumber/missingNumber.md: -------------------------------------------------------------------------------- 1 | # Missing number in array 2 | 3 | ## Problem 4 | 5 | Given an array containing _n_ distinct numbers taken from 0, 1, 2, ..., _n_, find the number that is missing from the array. 6 | 7 | ## Examples 8 | ``` 9 | Example 1: 10 | 11 | Input: [3,0,1] 12 | Output: 2 13 | 14 | Example 2: 15 | 16 | Input: [9,6,4,2,3,5,7,0,1] 17 | Output: 8 18 | ``` 19 | 20 | [Source](https://leetcode.com/problems/missing-number/) 21 | -------------------------------------------------------------------------------- /challenges/mode/modequestion.js: -------------------------------------------------------------------------------- 1 | // Given a set of numbers, how could you find the mode? 2 | // A mode is a value that appears most often in a set of data. 3 | // Create a function SimpleMode(arr). Let it take the array of numbers stored 4 | // in arr and return the number that appears most frequently (the mode). 5 | 6 | function SimpleMode(arr) { 7 | 8 | // code goes here 9 | return mode; 10 | } 11 | 12 | //submitted by Abby Garcia: https://github.com/abby-garcia 13 | -------------------------------------------------------------------------------- /challenges/mode/solutions/getMode.py: -------------------------------------------------------------------------------- 1 | import operator 2 | 3 | def getMode(L): 4 | V = {} 5 | 6 | #iterate through list once 7 | for x in L: 8 | if x in V: 9 | V[x] += 1 10 | else: 11 | V[x] = 1 12 | 13 | #use sorted & operator to sort python map in descending order and return most common value 14 | sorted_V = sorted(V.items(), key=operator.itemgetter(1), reverse=True) 15 | return sorted_V[0][0] 16 | 17 | 18 | if __name__ == "__main__": 19 | print getMode([1,3,3,2,5]) -------------------------------------------------------------------------------- /challenges/mode/solutions/modeanswer.js: -------------------------------------------------------------------------------- 1 | function SimpleMode(arr) { 2 | 3 | var map = {}; 4 | var mode = 0; 5 | var highestFreq = 0; 6 | 7 | for (var i = 0; i < arr.length; i++) { 8 | if (map[arr[i]]) { 9 | map[arr[i]]++; 10 | } else { 11 | map[arr[i]] = 1; 12 | } 13 | } 14 | 15 | for (var i = 0; i < arr.length; i++) { 16 | if (map[arr[i]] > highestFreq) { 17 | highestFreq = map[arr[i]]; 18 | mode = arr[i]; 19 | } 20 | } 21 | 22 | if (highestFreq !== 1) { 23 | return mode; 24 | } else { 25 | return -1; 26 | } 27 | 28 | return mode; 29 | } -------------------------------------------------------------------------------- /challenges/mode/solutions/simpleMode.js: -------------------------------------------------------------------------------- 1 | function SimpleMode(arr) { 2 | 3 | // initialize 4 | var num=arr[0], count = 1; maxCount = 0; mode =0; 5 | 6 | arr = arr.sort(); 7 | 8 | for(var i = 0; i< arr.length; i++){ 9 | 10 | if(count>maxCount){ 11 | mode = num; 12 | maxCount = count; 13 | } 14 | if(num === arr[i]){ 15 | count++; 16 | }else{ 17 | num = arr[i]; 18 | count = 1; 19 | } 20 | } 21 | 22 | return mode; 23 | } 24 | 25 | 26 | 27 | SimpleMode([1,1,4,450,450,450,450,7,2,2,2,23,4,23,5,8,8,7,8,8,8,8,8,7,8,8,333,4]) -------------------------------------------------------------------------------- /challenges/mountainClimbers/mountainClimbers.md: -------------------------------------------------------------------------------- 1 | # Mountain Climbers 2 | ## Prompt 3 | Given a 2 dimensional array of whole numbers please tell me the fewest amount of steps it would take to get from the smallest number to the highest number in the 2D array. Steps must be made to larger or same value numbers and can be horizontal and vertical but not diagonal. 4 | 5 | i.e. 2 -> 2 or 2 -> 4 but NOT 2 -> 1 6 | 7 | Example to give 8 | ``` 9 | [ 10 | [4, 5, 2], 11 | [3, 1, 6], 12 | [7, 8, 9] 13 | ] 14 | 15 | Steps = 2 16 | 17 | ``` -------------------------------------------------------------------------------- /challenges/multiplesOf3And5/multiplesOf3And5.md: -------------------------------------------------------------------------------- 1 | [The following problem is taken from Project Euler](https://projecteuler.net/problem=1) 2 | 3 | "If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. 4 | 5 | Find the sum of all the multiples of 3 or 5 below 1000." 6 | -------------------------------------------------------------------------------- /challenges/multiplesOf3And5/solutions/multiples3and5.py: -------------------------------------------------------------------------------- 1 | def multiplesof3and5(n): 2 | sum = 0 3 | i = 1 4 | while i < n: 5 | if (i % 3 == 0 or i % 5 == 0): 6 | sum += i 7 | i += 1 8 | return sum 9 | 10 | if __name__ == "__main__": 11 | print multiplesof3and5(1000) -------------------------------------------------------------------------------- /challenges/multiplesOf3And5/solutions/multiplesOf3And5.js: -------------------------------------------------------------------------------- 1 | function multipleSum(a, b, max){ 2 | var sum = 0; 3 | var x = 0; 4 | while(x < max) { 5 | if(x % 3 === 0 || x % 5 === 0){ 6 | sum += x; 7 | } 8 | x++; 9 | } 10 | return sum; 11 | } 12 | 13 | console.log(multipleSum(3,5, 1000) === 233168) //should return true 14 | -------------------------------------------------------------------------------- /challenges/multiplesOf3And5/solutions/objcMultiplesOf3And5.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MultiplesOf3And5 4 | // 5 | // Created by Julianne on 7/19/16. 6 | // Copyright © 2016 Julianne Goyena. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) { 12 | @autoreleasepool { 13 | 14 | // If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. 15 | // 16 | // Find the sum of all the multiples of 3 or 5 below 1000. 17 | 18 | int sum = 0; 19 | 20 | for (int i = 1; i < 1000; i++) { 21 | 22 | if (i % 3 == 0 || i % 5 == 0) 23 | sum += i; 24 | } 25 | 26 | NSLog(@"%i", sum); // prints 233168 27 | 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /challenges/multiplesOf3And5/solutions/sumOfMults.js: -------------------------------------------------------------------------------- 1 | //Completed by juicecrawl and ashes74 2 | 3 | function sumOfMults(num){ 4 | var m3 = 0, m5 = 0, array = []; 5 | 6 | //Create an array with all multiples of 3 < num 7 | for (var i=1; m3 +3 2 | 3 | Create a function called isPalindrome() that returns true or false depending on whether the string is a palindrome. 4 | 5 | A palindrome is a string of letters that can be read the same backward and forward. An example is 'Taco cat'. 6 | 7 | Extension: Make the function recursive. 8 | 9 | Submitted by [KamillaKhabibrakhmanova](https://github.com/KamillaKhabibrakhmanova) 10 | -------------------------------------------------------------------------------- /challenges/palindrome/solutions/isPalindrome.py: -------------------------------------------------------------------------------- 1 | 2 | # coding: utf-8 3 | 4 | # In[44]: 5 | 6 | #Python 2 7 | import string 8 | def isPalindrome(string): 9 | string = string.replace(" ","") 10 | if len(string) <= 1: 11 | return True 12 | elif string[0].lower() != string[len(string)-1].lower() : 13 | return False 14 | else: 15 | return isPalindrome(string[1:len(string)-1]) 16 | 17 | #print isPalindrome("Taco cat") 18 | #print isPalindrome("ABSDDSA") 19 | 20 | 21 | ## submitted by [jungjung917](https://github.com/jungjung917) 22 | -------------------------------------------------------------------------------- /challenges/palindrome/solutions/palindrome.rb: -------------------------------------------------------------------------------- 1 | def isPalindrome(word) 2 | return word.delete(' ').downcase == word.delete(' ').downcase.reverse 3 | end 4 | 5 | # puts isPalindrome("taco cat") 6 | # puts isPalindrome("Taco cat") 7 | # puts isPalindrome("dog") -------------------------------------------------------------------------------- /challenges/partitionLabels/partitionLabels.md: -------------------------------------------------------------------------------- 1 | # Partition Labels 2 | 3 | ## Problem 4 | 5 | A string S of lowercase letters is given. 6 | We want to partition this string into as many parts as possible so that each letter appears in at most one part, 7 | and return a list of integers representing the size of these parts. 8 | 9 | ## Example 10 | 11 | ``` 12 | Input: S = "ababcbacadefegdehijhklij" 13 | Output: [9,7,8] 14 | Explanation: 15 | The partition is "ababcbaca", "defegde", "hijhklij". 16 | This is a partition so that each letter appears in at most one part. 17 | A partition like "ababcbacadefegde", "hijhklij" is incorrect, because it splits S into less parts. 18 | 19 | ``` 20 | Note: 21 | 22 | S will have length in range [1, 500]. 23 | S will consist of lowercase letters ('a' to 'z') only. 24 | 25 | [Source](https://leetcode.com/problems/partition-labels/) 26 | -------------------------------------------------------------------------------- /challenges/partitionLinkedList/partitionLinkedList.md: -------------------------------------------------------------------------------- 1 | ## Partition a linked list 2 | Problem found on [LeetCode OJ](https://leetcode.com/problems/partition-list/) 3 | 4 | Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. 5 | 6 | submitted by [lei-clearsky](https://github.com/lei-clearsky) 7 | -------------------------------------------------------------------------------- /challenges/passwordGenerator/passwordGenerator.md: -------------------------------------------------------------------------------- 1 | # Password generator 2 | 3 | ## Problem 4 | 5 | Create a password generation program which will generate passwords containing random ASCII characters from the following groups: 6 | 7 | ``` 8 | lower-case letters: a ──► z 9 | upper-case letters: A ──► Z 10 | digits: 0 ──► 9 11 | other printable characters: !"#$%&'()*+,-./:;<=>?@[]^_{|}~ 12 | (the above character list excludes white-space, backslash and backtick) 13 | ``` 14 | 15 | The generated password(s) must include: 16 | ``` 17 | at least one lower-case letter 18 | at least one upper-case letter 19 | at least one digit (numeral) 20 | at least one symbol/"other" character 21 | ``` 22 | 23 | The user must be able to specify the password length and the number of passwords to generate. 24 | 25 | The passwords should be displayed or written to a file, one per line. 26 | 27 | Extra credit: 28 | Allow the user to specify a seed value. 29 | 30 | Give the option of excluding visually similar characters, such as `l, I, 1` and `O, 0`. 31 | 32 | [Source](http://rosettacode.org/wiki/Password_generator) 33 | -------------------------------------------------------------------------------- /challenges/perfectNumbers/perfectNumbers.md: -------------------------------------------------------------------------------- 1 | # Perfect numbers 2 | 3 | A [perfect number](https://en.wikipedia.org/wiki/Perfect_number) is a positive integer that is the sum of its proper positive divisors excluding the number itself. 4 | 5 | Equivalently, a perfect number is a number that is half the sum of all of its positive divisors (including itself). 6 | 7 | ## Problem 8 | 9 | Write a function which says whether a number is perfect. 10 | 11 | ## Example 12 | 13 | ```javascript 14 | f(28) 15 | // => true 16 | 17 | f(29) 18 | // => false 19 | ``` 20 | 21 | [Source](http://rosettacode.org/wiki/Perfect_numbers) 22 | -------------------------------------------------------------------------------- /challenges/permutate/permutate.md: -------------------------------------------------------------------------------- 1 | **Level 5**
2 | 3 | Create a function called permutate() to return an array of all the different permutations of the letters in a string. Your input will be a string consisting of three characters and the return value should be an array of strings. If the input is not a string, return false. 4 | 5 | Example: permutate('abc') should return ['abc', 'acb', 'bac', 'bca', 'cba', 'cab']. 6 | 7 | Submitted by [KamillaKhabibrakhmanova](https://github.com/KamillaKhabibrakhmanova) 8 | -------------------------------------------------------------------------------- /challenges/permutate/solutions/javascript.js: -------------------------------------------------------------------------------- 1 | function permutation(inputStr){ 2 | var results = []; 3 | 4 | var inputArr = inputStr.split(''); 5 | function permute(arr, memo) { 6 | var cur, memo = memo || []; 7 | 8 | for (var i = 0; i < arr.length; i++) { 9 | cur = arr.splice(i, 1); 10 | if (arr.length === 0) { 11 | results.push(memo.concat(cur)); 12 | } 13 | permute(arr.slice(), memo.concat(cur)); 14 | arr.splice(i, 0, cur[0]); 15 | } 16 | var permutation = [] 17 | results.forEach(function(perm){permutation.push(perm.join(""))}); 18 | return permutation; 19 | } 20 | 21 | return permute(inputArr); 22 | } 23 | 24 | // submitted by [Karen J. Mao](https://github.com/mikuya707) 25 | -------------------------------------------------------------------------------- /challenges/permutate/solutions/permutate.py: -------------------------------------------------------------------------------- 1 | #python 2 2 | def permutate(inputString): 3 | if not isinstance(inputString,basestring): 4 | return False 5 | elif len(inputString) <= 1: 6 | return inputString 7 | else: 8 | stringArray = [inputString[0]] 9 | j = 1 10 | 11 | def permutatation(stringArray, j): 12 | stringArray1=set() 13 | if j >= len(inputString): 14 | return stringArray 15 | else: 16 | for strings in stringArray: 17 | for i in range(0,len(strings)+1): 18 | stringArray1.add(strings[:i]+inputString[j]+strings[i:]) 19 | stringArray = list(stringArray1) 20 | return permutatation(stringArray, j+1) 21 | 22 | return permutatation(stringArray, j) 23 | print permutate('abc') 24 | 25 | ## submitted by [jungjung917](https://github.com/jungjung917) 26 | -------------------------------------------------------------------------------- /challenges/pigLatin/pigLatin.md: -------------------------------------------------------------------------------- 1 | ## Pig Latin 2 | 3 | Create a function that will take a string and return its pig latin equivalent. 4 | 5 | Rules for pig latin taken from [Pig Latin Translator](http://www.snowcrest.net/donnelly/piglatin.html) 6 | 7 | submitted by [Julie Kwok](https://github.com/kwokster10) 8 | -------------------------------------------------------------------------------- /challenges/pigLatin/solutions/pigLatin.js: -------------------------------------------------------------------------------- 1 | function pig_latin_translator(words) { 2 | var vowel = "aeiou", 3 | inputArr = words.split(" "), 4 | resultArray = [], 5 | index = 0, 6 | start, 7 | end; 8 | 9 | inputArr.forEach(function(word) { 10 | for (var i = 0; i < word.length; i++) { 11 | if (vowel.indexOf(word[i]) !== -1) { 12 | if (word[i] != "u" || (word[i] === "u" && word[i-1] !== "q")) { 13 | index = i; 14 | break; 15 | } 16 | } 17 | } 18 | 19 | start = word.substring(index, word.length); 20 | end = word.substring(0, index) + "ay"; 21 | 22 | resultArray.push( start + end ); 23 | }); 24 | 25 | return resultArray.join(" "); 26 | } 27 | 28 | pig_latin_translator("the quick brown fox"); // return 'ethay ickquay ownbray oxfay' 29 | 30 | submitted by [lei-clearsky](https://github.com/lei-clearsky) 31 | -------------------------------------------------------------------------------- /challenges/pigLatin/solutions/pigLatin.py: -------------------------------------------------------------------------------- 1 | #submitted by [Julie Kwok](https://github.com/kwokster10) 2 | 3 | # regex library 4 | import re 5 | 6 | def pig_latin_translator(word): 7 | # checks that a word (only letters) is passed in 8 | if re.match('^[A-Z]+$', word, flags=re.I): 9 | # change case to lowercase 10 | word = word.lower() 11 | # checks for qu words 12 | if re.match('\Aqu', word): 13 | return "%squay" % word[2:] 14 | # checking to see if the word starts with a vowel 15 | elif re.match('(\A[aeiou])', word): 16 | return '%sway' % word 17 | else: 18 | # index of first vowel of word if it doesn't begin with y 19 | if word[0] != "y": 20 | first_vowel = re.search('[aeiouy]', word) 21 | else: 22 | first_vowel = re.search('[aeiou]', word) 23 | 24 | v_index = word.index(word[first_vowel.start()]) 25 | return "%s%say" % (word[v_index:], word[:v_index]) 26 | else: 27 | return "Sorry, I only take one word composed of only letters." 28 | -------------------------------------------------------------------------------- /challenges/pigLatin/solutions/pigLatin.rb: -------------------------------------------------------------------------------- 1 | def translate(word) 2 | change = false 3 | 4 | if word == word.capitalize 5 | word.downcase! 6 | change = true 7 | end 8 | 9 | if (word[0] =~ /[aeiou]/) 10 | word = word + 'way' 11 | elsif word.include?('qu') && (word.index('qu') == 0) 12 | word = word[2..-1].concat('quay') 13 | else 14 | idx = word.index(/[aeiou]/) 15 | word = word[idx..-1].concat(word[0...idx]).concat('ay') 16 | end 17 | 18 | word.capitalize! if change 19 | return word 20 | end 21 | 22 | 23 | def pig_latin(str) 24 | result = str.split(" ").map { |word| 25 | translate(word) 26 | }.join(" ") 27 | result 28 | end 29 | 30 | p pig_latin("Quiet tree") =="Ietquay eetray" 31 | p pig_latin("apple quick Fox") == "appleway ickquay Oxfay" 32 | 33 | #submitted by [Iuliia Kotlenko](https://github.com/IuliiaKot) 34 | -------------------------------------------------------------------------------- /challenges/powerOfTwo/powerOfTwo.md: -------------------------------------------------------------------------------- 1 | How could you check to see if a given number is a power of 2? How could you do so using [bit manipulation](http://www.codeproject.com/Articles/2247/An-introduction-to-bitwise-operators)? 2 | 3 | //////////////////////////////////////////////////////////// 4 | // Aksana Kuzmitskaya 5 | // aksana.kuzmitskaya@gmail.com 6 | /////////////////////////////////////////////////////////// 7 | -------------------------------------------------------------------------------- /challenges/powerOfTwo/solutions/powerOfTwo.cpp: -------------------------------------------------------------------------------- 1 | //From wikipedia: https://en.wikipedia.org/wiki/Bit_manipulation 2 | 3 | // The obvious method 4 | unsigned int x = ...; 5 | bool isPowerOfTwo; 6 | if (x > 0) { 7 | while ((x % 2) == 0) { 8 | x = x / 2; 9 | } 10 | isPowerOfTwo = (x==1); 11 | } 12 | else 13 | isPowerOfTwo = false; 14 | 15 | // A method using bit manipulation 16 | bool isPowerOfTwo = x && !(x & (x - 1)); 17 | 18 | //////////////////////////////////////////////////////////// 19 | // Aksana Kuzmitskaya 20 | // aksana.kuzmitskaya@gmail.com 21 | /////////////////////////////////////////////////////////// 22 | -------------------------------------------------------------------------------- /challenges/powerOfTwo/solutions/powerOfTwo.py: -------------------------------------------------------------------------------- 1 | # Submitted by Beverly23 2 | 3 | 4 | def shiftBits(num, i): 5 | new_num = 1 << i 6 | if num == new_num: 7 | return True 8 | elif num < new_num: 9 | return False 10 | else: 11 | return shiftBits(num, i + 1) 12 | 13 | 14 | def isPowerOfTwo(num): 15 | return shiftBits(num, 1) 16 | 17 | print isPowerOfTwo(0) 18 | print isPowerOfTwo(None) 19 | print isPowerOfTwo(1) 20 | print isPowerOfTwo(10) 21 | print isPowerOfTwo(64) 22 | print isPowerOfTwo(-64) 23 | print isPowerOfTwo(1048576) 24 | -------------------------------------------------------------------------------- /challenges/powerOfTwo/solutions/powerOfTwo.rb: -------------------------------------------------------------------------------- 1 | def power_of_2?(number) 2 | return false if number == 0 || number == 1 3 | while (number % 2 == 0) 4 | number /= 2 5 | end 6 | return number > 1 ? false : true 7 | end 8 | 9 | p power_of_2?(0) == false 10 | p power_of_2?(1) == false 11 | p power_of_2?(4) == true 12 | p power_of_2?(5) == false 13 | p power_of_2?(12) == false 14 | p power_of_2?(64) == true 15 | 16 | def power_of_two?(number) 17 | return number & (number - 1) == 0 18 | end 19 | 20 | p power_of_two?(4) == true 21 | p power_of_two?(5) == false 22 | p power_of_two?(12) == false 23 | 24 | #submitted by [Iuliia Kotlenko](https://github.com/IuliiaKot) 25 | -------------------------------------------------------------------------------- /challenges/powerSet/powerSet.md: -------------------------------------------------------------------------------- 1 | # Power set 2 | 3 | A set is a collection of values, without any particular order, and no repeated values. 4 | 5 | Given a set S, the [power set](https://en.wikipedia.org/wiki/Power_set) (or powerset) of S, written P(S), or 2S, is the set of all subsets of S. 6 | 7 | ## Problem 8 | 9 | Write a function with a set S as input that yields the power set 2S of S. 10 | 11 | For a set which contains n elements, the corresponding power set has 2n elements, including the edge cases of [empty set](https://en.wikipedia.org/wiki/Empty_set). 12 | 13 | ## Example 14 | 15 | ```javascript 16 | f([1,2,3,4]) 17 | // => [], [1], [2], [1,2], [3], [1,3], [2,3], [1,2,3], [4], [1,4], [2,4], [1,2,4], [3,4], [1,3,4], [2,3,4], [1,2,3,4] 18 | ``` 19 | 20 | [Source](http://rosettacode.org/wiki/Power_set) 21 | -------------------------------------------------------------------------------- /challenges/powerSet/solutions/powerSet.py: -------------------------------------------------------------------------------- 1 | 2 | def power_set(s): 3 | 4 | all_subsets = [set()] 5 | if len(s) == 0: 6 | return all_subsets 7 | power_set_helper(s.copy(), all_subsets) 8 | return all_subsets 9 | 10 | 11 | def power_set_helper(s, all_subsets): 12 | 13 | if len(s) == 1: 14 | all_subsets.append(set(s)) 15 | else: 16 | first_item = s[0] 17 | s = s[1:] 18 | power_set_helper(s, all_subsets) 19 | copy_all_subsets = all_subsets.copy() 20 | for subset in copy_all_subsets: 21 | all_subsets.append(subset | {first_item}) 22 | 23 | 24 | def main(): 25 | print(power_set([1, 2, 3])) 26 | print(power_set([])) 27 | 28 | 29 | if __name__ == '__main__': 30 | main() 31 | -------------------------------------------------------------------------------- /challenges/primeFactors/primeFactors.md: -------------------------------------------------------------------------------- 1 | [The following problem is taken from Project Euler](https://projecteuler.net/problem=3) 2 | 3 | "The prime factors of 13195 are 5, 7, 13 and 29. 4 | 5 | What is the largest prime factor of the number 600851475143 ?" 6 | -------------------------------------------------------------------------------- /challenges/primeFactors/solutions/largestPrimeFactor.py: -------------------------------------------------------------------------------- 1 | def largestPrimeFactor(n): 2 | 3 | #using sieve of erastosthenes to generate primes 4 | prime_nums = [] 5 | for i in xrange(0,n+1): 6 | prime_nums.append(0) 7 | 8 | k = 2 9 | while k <= n: 10 | #it is still prime 11 | if (prime_nums[k] == 0): 12 | i = k * 2 13 | while i <= n: 14 | prime_nums[i] = 1 15 | i += k 16 | k += 1 17 | 18 | #then grabbing the largest prime factor from our generated list 19 | index = n 20 | while index > 0: 21 | if (prime_nums[index] == 0 and n % index == 0): 22 | return index 23 | index -= 1 24 | 25 | return False 26 | 27 | if __name__ == "__main__": 28 | print largestPrimeFactor(1000) 29 | print largestPrimeFactor(13195) -------------------------------------------------------------------------------- /challenges/primeFactors/solutions/primeFactors.js: -------------------------------------------------------------------------------- 1 | ///VERY INEFFICIENT SOLUTION...can you do better ? :) 2 | function isPrime(x){ 3 | var y = 2; 4 | while(y < x){ 5 | if (x % y === 0) { 6 | return false; 7 | } 8 | y++; 9 | } 10 | return true; 11 | } 12 | 13 | function isFactor(potentialFactor, num){ 14 | return num % potentialFactor === 0; 15 | } 16 | 17 | function largestPrimeFactor(num) { 18 | var x = num; 19 | while(x > 0){ 20 | if(isPrime(x)){ 21 | if(isFactor(x, num)){ 22 | return x; 23 | } 24 | } 25 | x--; 26 | } 27 | } 28 | 29 | console.log(largestPrimeFactor(13195)===29) //should equal true 30 | -------------------------------------------------------------------------------- /challenges/primeSum/primeSum.md: -------------------------------------------------------------------------------- 1 | ### Prime Sum 2 | 3 | Given an even number (greater than 2), return two prime numbers whose sum will be equal to given number. ([A solution will always exist](https://en.wikipedia.org/wiki/Goldbach%27s_conjecture)!) 4 | 5 | [Source](https://www.interviewbit.com/problems/prime-sum/) 6 | -------------------------------------------------------------------------------- /challenges/primesBase10/primesBase10.md: -------------------------------------------------------------------------------- 1 | Find all numbers below 10,000 that are both prime, and all their digits in base 10 are prime. [Source](http://golf.shinh.org/p.rb?Primarily+Prime+Primes) 2 | -------------------------------------------------------------------------------- /challenges/productOfIntegers/productOfIntegers.md: -------------------------------------------------------------------------------- 1 | ## Get products of all integers 2 | 3 | You have a list of integers, and for each index you want to find the product of every integer except the integer at that index. 4 | Write a function get_products_of_all_ints_except_at_index() that takes a list of integers and returns a list of the products. 5 | 6 | *For example, given: 7 | 8 | [1, 7, 3, 4] 9 | 10 | Your function should return: 11 | 12 | [84, 12, 28, 21] 13 | 14 | by calculating: 15 | 16 | [7*3*4, 1*3*4, 1*7*4, 1*7*3]* 17 | 18 | 19 | 20 | **Do not use division in your solution.** 21 | 22 | submitted by [Iuliia Kotlenko](https://github.com/IuliiaKot) 23 | -------------------------------------------------------------------------------- /challenges/productOfIntegers/solutions/productOfIntegers.js: -------------------------------------------------------------------------------- 1 | function productOfIntegers(array){ 2 | 3 | var result=[]; 4 | 5 | //We multiply the values until the array length 6 | var productSoFar=1; // We initialize in one so when we multiply in that index it returns its own: 3 X 1 = 3 7 | for(var i=0; i < array.length; i++) 8 | { 9 | result[i] = productSoFar; 10 | productSoFar *= array[i]; 11 | } 12 | 13 | //We multiply the values reading the array backwards 14 | productSoFar=1; //We need to initialize teh product again to 1 15 | for(var j= array.length-1; j>=0;j--) 16 | { 17 | result[j] *= productSoFar; 18 | productSoFar *= array[j]; 19 | } 20 | 21 | return result; 22 | } 23 | 24 | console.log(productOfIntegers([1, 7, 3, 4])); -------------------------------------------------------------------------------- /challenges/productOfIntegers/solutions/productOfIntegers.py: -------------------------------------------------------------------------------- 1 | """Algorithm@Betterment: Jan 20,2016 2 | 3 | Problem 1: Get products of all integers 4 | 5 | You have a list of integers, and for each index you want to find the product of 6 | every integer except the integer at that index. Write a function 7 | get_products_of_all_ints_except_at_index() that takes a list of integers 8 | and returns a list of the products. 9 | 10 | *For example, given: 11 | [1, 7, 3, 4] 12 | Your function should return: 13 | [84, 12, 28, 21] 14 | by calculating: 15 | [734, 134, 174, 173]* 16 | Do not use division in your solution. 17 | 18 | submitted by https://github.com/mmeric 19 | """ 20 | 21 | from functools import reduce 22 | import operator 23 | 24 | def prodint(data): 25 | result = [] 26 | for i in range(len(data)): 27 | idata = data[:i] + data[i+1:] 28 | #ip = reduce(lambda x,y: x*y, idata) 29 | ip = reduce(operator.mul, idata) 30 | result.append(ip) 31 | return result 32 | 33 | data = [1,7,3,4] 34 | print(prodint(data)) 35 | -------------------------------------------------------------------------------- /challenges/quickSort/solutions/quickSort.js: -------------------------------------------------------------------------------- 1 | // ES6 solution adapted from Rosetta Code 2 | // http://rosettacode.org/wiki/Sorting_algorithms/Quicksort#JavaScript 3 | 4 | Array.prototype.quick_sort = function () { 5 | if (this.length < 2) { return this; } 6 | 7 | var pivot = this[Math.floor(Math.random() * this.length)]; 8 | 9 | return this.filter(x => x < pivot) 10 | .quick_sort() 11 | .concat(this.filter(x => x == pivot)) 12 | .concat(this.filter(x => x > pivot).quick_sort()); 13 | }; 14 | -------------------------------------------------------------------------------- /challenges/rainWaterCollector/rainWaterCollector.md: -------------------------------------------------------------------------------- 1 | ##Rain Water Collector 2 | 3 | **PROBLEM**: Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water your collection device is able to trap after raining. 4 | 5 | **EXAMPLE**: Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6. 6 | 7 | Visual Representation of above: 8 | 9 | 10 | -------------------------------------------------------------------------------- /challenges/rainWaterCollector/solutions/rainWaterCollector.js: -------------------------------------------------------------------------------- 1 | function totalVol(arr) { 2 | var peak = Math.max.apply(null, arr); 3 | var vol = 0 4 | 5 | for (var height = peak; height > 0; height--) { 6 | var peaksAtHeightLevel = peakIndicesMaker(arr,height); 7 | vol += volAtLevel(peaksAtHeightLevel); 8 | } 9 | return vol; 10 | } 11 | 12 | function peakIndicesMaker(arr,level) { 13 | var peakIndices = []; 14 | 15 | for (var i = 0; i < arr.length; i++) { 16 | if(arr[i] >= level) { 17 | peakIndices.push(i); 18 | } 19 | } 20 | return peakIndices; 21 | } 22 | 23 | function volAtLevel(peakIndices) { 24 | var levelVol = 0 25 | if(peakIndices.length === 1) { 26 | return 0; 27 | } else { 28 | for (var i = 0; i < (peakIndices.length-1); i++) { 29 | levelVol += (peakIndices[i+1] - (peakIndices[i]+1)); 30 | }; 31 | } 32 | return levelVol 33 | } 34 | -------------------------------------------------------------------------------- /challenges/range/range.md: -------------------------------------------------------------------------------- 1 | Write a program that prints out all integers in a range (x, y). 2 | 3 | Can you write this program iteratively? Recursively? 4 | -------------------------------------------------------------------------------- /challenges/range/solutions/objcRange.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Range 4 | // 5 | // Created by Julianne on 8/12/16. 6 | // Copyright © 2016 Julianne Goyena. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | void printIntegersIteratively(int x, int y) { 12 | 13 | for (int i = x; i <= y; i++) { 14 | NSLog(@"%i\n", i); 15 | } 16 | } 17 | 18 | void printIntegersRecursively(int x, int y) { 19 | 20 | int i = x; 21 | 22 | if (i == y) { 23 | NSLog(@"%i\n", i); 24 | } 25 | else { 26 | NSLog(@"%i\n", i); 27 | printIntegersRecursively(x + 1, y); 28 | } 29 | } 30 | 31 | int main(int argc, const char * argv[]) { 32 | @autoreleasepool { 33 | 34 | // Write a program that prints out all integers in a range (x, y). 35 | // 36 | // Can you write this program iteratively? Recursively? 37 | 38 | printIntegersIteratively(1, 10); 39 | printIntegersRecursively(1, 10); 40 | 41 | } 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /challenges/range/solutions/range.js: -------------------------------------------------------------------------------- 1 | function print(x,y) { 2 | var arr=[]; 3 | 4 | for (var i=x; i<=y; i++) { 5 | arr.push(i) 6 | } 7 | 8 | return arr 9 | } 10 | 11 | print(4,100) 12 | 13 | -------------------------------------------------------------------------------- /challenges/removeDuplicatesInString/removeDuplicatesInString.md: -------------------------------------------------------------------------------- 1 | # Remove duplicate characters in a string 2 | 3 | ## Problem 4 | 5 | Remove duplicate characters in a given string keeping only the first occurrences. 6 | 7 | ## Example 8 | ```javascript 9 | f('important bear') 10 | // => 'importan be' 11 | ``` 12 | 13 | [Source](http://www.ardendertat.com/2012/01/06/programming-interview-questions-25-remove-duplicate-characters-in-string/) 14 | -------------------------------------------------------------------------------- /challenges/removeDuplicatesInStringII/removeDuplicatesInStringII.md: -------------------------------------------------------------------------------- 1 | # Remove duplicate characters in a string, hard mode 2 | 3 | ## Problem 4 | 5 | Given a string which contains only lowercase letters, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the **smallest in lexicographical order among all possible results**. 6 | 7 | ## Examples 8 | 9 | ```javascript 10 | f("bcabc") 11 | // => "abc" 12 | 13 | f("cbacdcbc") 14 | // => "acdb" 15 | ``` 16 | 17 | [Source](https://leetcode.com/problems/remove-duplicate-letters/) 18 | -------------------------------------------------------------------------------- /challenges/removeVowels/removeVowels.md: -------------------------------------------------------------------------------- 1 | **Level 1**
2 | Create a function called removeVowels() to remove all the vowels in a given string. Both uppercase and lowercase vowels should be removed. Your input will be a string and you should return the string without any vowels. 3 | 4 | submitted by https://github.com/seemaullal 5 | -------------------------------------------------------------------------------- /challenges/removeVowels/solutions/pseudocode.md: -------------------------------------------------------------------------------- 1 | Psuedocode 2 | ``` 3 | function removeVowels(string) 4 | tmpString = '' 5 | loop through each letter of the string 6 | if the letter is not a vowels 7 | add it to tmpString 8 | return tmpString 9 | ``` 10 | 11 | A Javascript solution 12 | ``` javascript 13 | function removeVowels(str) { 14 | var tmpStr = '', vowels = ['a','e','i','o','u']; 15 | for (var i = 0; i 2 | 3 | Create a function called repeatify that takes in two arguments as the input - a string and a number. The function should return the string repeated the given numberof times. If the first argument is not a string or the second argument is not a number, return false. 4 | 5 | Example: repeatify('hello',3) should return 'hellohellohello'. 6 | 7 | Extension: Write the function without using a 'for' loop 8 | 9 | Submitted by [KamillaKhabibrakhmanova](https://github.com/KamillaKhabibrakhmanova) 10 | -------------------------------------------------------------------------------- /challenges/repeatify/solutions/javascript.js: -------------------------------------------------------------------------------- 1 | function repeatify(str, num) { 2 | if (typeof str !== "string" || typeof num !== 'number') 3 | return false; 4 | //creates an empty of size n+1 and uses the str string to join the empty elements 5 | //since there are "n" spaces between the "n+1" empty elements of the array, the str 6 | //string will be inserted in each space (resulting in the repeated string we want) 7 | return Array(num+1).join(str); 8 | } 9 | 10 | submitted by [seemaullal](https://github.com/seemaullal) 11 | -------------------------------------------------------------------------------- /challenges/repeatify/solutions/repeatify.py: -------------------------------------------------------------------------------- 1 | #Python 2 2 | #Python 3, use: isinstance(string, str) 3 | def repeatify(string, number): 4 | if not isinstance(number, int) or not isinstance(string, basestring): 5 | return False 6 | elif number == 0: 7 | return "" 8 | else: 9 | return string + repeatify(string, number - 1) 10 | 11 | #print repeatify("Hello", 3) 12 | #print repeatify(3,3) 13 | #print repeatify("Hello","hi") 14 | 15 | ## submitted by [jungjung917](https://github.com/jungjung917) 16 | -------------------------------------------------------------------------------- /challenges/repeatify/solutions/ruby.rb: -------------------------------------------------------------------------------- 1 | def repeatify(str, count) 2 | return false unless (str.kind_of?(String) && count.kind_of?(Integer)) 3 | return str*count 4 | end 5 | 6 | p repeatify("hello", 3) == "hellohellohello" 7 | p repeatify("hello", "f") == false 8 | p repeatify(4, 3) == false 9 | 10 | # submitted by [Iuliia Kotlenko](https://github.com/IuliiaKot) 11 | -------------------------------------------------------------------------------- /challenges/reverse/reverse.md: -------------------------------------------------------------------------------- 1 | **Level 6**
2 | 3 | Create a function called reverse() that takes in a set of key-value pairs (object in Javascript, hash in Ruby, dictionary in Python, etc.) as the input and returns an object with the same keys and values inverted. If multiple keys have the same value, it should assign of array of keys. 4 | 5 | Example: 6 | inputObject: {'a':1, 'b':2} 7 | 8 | `reverse(inputObject)` should return {1:'b', 2:'c'} 9 | 10 | inputObject2 = { 11 | "a": "1", 12 | "b": "2", 13 | "c": "1", 14 | "d": "3" 15 | } 16 | 17 | `reverse(inputObject2)` should return { 18 | "1": ["a", "c"], 19 | "2": ["b"] 20 | "3": ["d"] 21 | } 22 | 23 | Submitted by [KamillaKhabibrakhmanova](https://github.com/KamillaKhabibrakhmanova) 24 | -------------------------------------------------------------------------------- /challenges/reverse/solutions/javascript.js: -------------------------------------------------------------------------------- 1 | function reverse(obj) { 2 | var newObj = { }; 3 | //you could use a `for var key in obj` loop but then should check Object.hasOwnProperty(key) 4 | //See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty for more 5 | var objKeys = Object.keys(obj); 6 | for (var i=0; i < objKeys.length; i++) { 7 | var curVal = obj[objKeys[i]]; 8 | if (typeof newObj[curVal] === "undefined") { 9 | newObj[curVal] = [ objKeys[i] ]; 10 | } else { 11 | newObj[curVal].push(objKeys[i]); 12 | } 13 | } 14 | return newObj; 15 | } 16 | 17 | submitted by [seemaullal](https://github.com/seemaullal) 18 | -------------------------------------------------------------------------------- /challenges/reverse/solutions/reverce.py: -------------------------------------------------------------------------------- 1 | #Python 2 2 | def reverse(inputDict): 3 | outputDict = {} 4 | for key, value in inputDict.iteritems(): 5 | if value not in outputDict.keys(): 6 | outputDict[value] = [key] 7 | else: 8 | outputDict[value].append(key) 9 | return outputDict 10 | #object1 = {'a':1,'b':2} 11 | #object2 = {'a':'1','b':'2','c':'1','d':'3'} 12 | #print reverse(object1) 13 | #print reverse(object2) 14 | 15 | 16 | ## submitted by [jungjung917](https://github.com/jungjung917) 17 | -------------------------------------------------------------------------------- /challenges/reverse/solutions/reverse.js: -------------------------------------------------------------------------------- 1 | var obj = { 2 | "a": 1, 3 | "b": 2, 4 | "c": 1, 5 | "d": 3 6 | }; 7 | 8 | function reverse(obj) { 9 | var reversed = {}; 10 | for (var key in obj) { 11 | var value = obj[key]; 12 | if (reversed[value]) { 13 | reversed[value].push(key); 14 | } else { 15 | reversed[value] = [key]; 16 | } 17 | } 18 | return reversed; 19 | } 20 | 21 | reverse(obj); 22 | 23 | //submitted by Tiffany Poss https://github.com/tiffanyposs -------------------------------------------------------------------------------- /challenges/reverseInteger/reverseInteger.md: -------------------------------------------------------------------------------- 1 | ## LeetCode - Easy. Reverse Integer 2 | ## Problem 3 | Given a 32-bit signed integer, reverse digits of an integer. 4 | 5 | 6 | Note: 7 | Assume we are dealing with an environment which could only store integers within t 8 | he 32-bit signed integer range: [−2^31, 2^31 − 1]. 9 | For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows. 10 | 11 | 12 | ## Example 1 13 | ``` 14 | Input: 123 15 | Output: 321 16 | ``` 17 | 18 | ## Example 2 19 | ``` 20 | Input: -123 21 | Output: -321 22 | ``` 23 | 24 | ## Example 3 25 | ``` 26 | Input: 120 27 | Output: 21 28 | ``` 29 | [Source](https://leetcode.com/problems/reverse-integer/) 30 | -------------------------------------------------------------------------------- /challenges/reverseSublist/reverseSublist.md: -------------------------------------------------------------------------------- 1 | ## Reverse sublist K at a time 2 | 3 | This problem entails reversing sublists of a given singly [linked list](https://en.wikipedia.org/wiki/Linked_list) k at a time. 4 | Write a function which takes as input a singly linked list L and a nonnegative integer k, 5 | and reverses the least k nodes at a time. If the number of nodes n in the list is not multiply of k, 6 | leave the last n mod k nodes unchanged. Do not change the data stored within a node. 7 | 8 | 9 | /************************************ 10 | Aksana Kuzmitskaya 11 | aksana.kuzmitskaya@gmail.com 12 | ************************************/ 13 | -------------------------------------------------------------------------------- /challenges/rockPaperScissors/rockPaperScissors.md: -------------------------------------------------------------------------------- 1 | Rock Paper Scissors 2 | 3 | Write a program that can take in two responses for a 4 | rock-paper-scissors game and declare who the winner is. [source](http://golf.shinh.org/p.rb?RPS+winner) 5 | 6 | Easy mode: Given an input like "Rock Paper", output the winner ("Paper"). If they're both the same, output the move once. 7 | 8 | Hard mode: Take in a custom move list, like in [Rock Paper Scissors Lizard Spock](http://www.samkass.com/theories/RPSSL.html), and judge winners the same way. You can decide the format for your input. 9 | -------------------------------------------------------------------------------- /challenges/rockPaperScissors/solutions/rocksPaperScissors.js: -------------------------------------------------------------------------------- 1 | function RPS(play1, play2) { 2 | //nest three options 3 | if (play1===play2) { 4 | return "tie"; 5 | } 6 | 7 | if (play1==="rock") { 8 | if (play2==="paper") { 9 | return "paper"; 10 | } else if (play2==="scissors") { 11 | return "rock"; 12 | } 13 | } 14 | 15 | if (play1==="paper") { 16 | if (play2==="rock") { 17 | return "paper"; 18 | } else if (play2==="scissors") { 19 | return "scissors"; 20 | } 21 | } 22 | 23 | if (play1==="scissors") { 24 | if (play2==="rock") { 25 | return "rock"; 26 | 27 | }else if (play2==="paper") { 28 | return "scissors"; 29 | } 30 | } 31 | } 32 | 33 | RPS("scissors", "scissors") 34 | -------------------------------------------------------------------------------- /challenges/romanNumerals/solutions/roman_numerals.rb: -------------------------------------------------------------------------------- 1 | def convert_to_roman(num, options={}) 2 | result = "" 3 | 4 | roman_numerals = { 5 | 1000 => "M", 6 | 500 => "D", 7 | 100 => "C", 8 | 50 => "L", 9 | 10 => "X", 10 | 5 => "V", 11 | 1 => "I" 12 | } 13 | 14 | while num >= 1 15 | roman_numerals.each do |arabic, roman| 16 | quotient = num / arabic 17 | result << roman * quotient 18 | num -= arabic * quotient 19 | break if num == 0 20 | end 21 | end 22 | 23 | if options[:modern] 24 | issues = { 25 | "VIIII" => "IX", 26 | "IIII" => "IV", 27 | "LXXXX" => "XC", 28 | "XXXX" => "XL", 29 | "DCCCC" => "CM", 30 | "CCCC" => "CD" 31 | } 32 | 33 | issues.each do |current, fix| 34 | result = result.sub(current, fix) if result.include?(current) 35 | end 36 | end 37 | 38 | result 39 | end 40 | -------------------------------------------------------------------------------- /challenges/rotateMatrix/rotateMatrix.md: -------------------------------------------------------------------------------- 1 | ### Rotate Matrix 2 | 3 | You are given an n x n 2D matrix representing an image. 4 | 5 | Rotate the image by 90 degrees (clockwise). 6 | 7 | Bonus: Try to do this without using an additional array! 8 | 9 | Example: 10 | ``` 11 | Input: 12 | [ 13 | [1, 2, 3], 14 | [4, 5, 6], 15 | [7, 8, 9] 16 | ] 17 | 18 | Output: 19 | [ 20 | [7, 4, 1], 21 | [8, 5, 2], 22 | [9, 6, 3] 23 | ] 24 | ``` 25 | 26 | [Source](https://www.interviewbit.com/problems/rotate-matrix/) 27 | -------------------------------------------------------------------------------- /challenges/searchInsertPosition/searchInsertPosition.md: -------------------------------------------------------------------------------- 1 | # Search insert position 2 | 3 | ## Problem 4 | 5 | Given a sorted array and a target value, return the index if the target is found. 6 | If it isn't found, return the index where it would be if it were inserted in order. 7 | You may assume no duplicates in the array. 8 | 9 | ## Example 10 | 11 | ``` 12 | Input: [1,3,5,6], 5 13 | 14 | Output: 2 15 | ``` 16 | 17 | [Source](https://leetcode.com/problems/search-insert-position/) 18 | -------------------------------------------------------------------------------- /challenges/segregateEvenOdd/segregateEvenOdd.js: -------------------------------------------------------------------------------- 1 | function sort(arr){ 2 | let even = []; 3 | let odd = []; 4 | 5 | for (var i = 0; i counts[Character.getNumericValue(nStr.charAt(i))]++); 10 | boolean selfDescribing = true; 11 | 12 | for (int i = 0; i < nStr.length(); i++) { 13 | selfDescribing &= Character.getNumericValue(nStr.charAt(i)) == counts[i]; 14 | } 15 | 16 | return selfDescribing; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /challenges/selfDescribingNumbers/testing/SelfDescribingNumbersTest.java: -------------------------------------------------------------------------------- 1 | package solutions; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | public class SelfDescribingNumbersTest { 8 | 9 | @Test 10 | public void test1() { 11 | assertTrue(SelfDescribingNumbers.isSelfDescribing(2020)); 12 | } 13 | 14 | @Test 15 | public void test2() { 16 | assertTrue(SelfDescribingNumbers.isSelfDescribing(1210)); 17 | } 18 | 19 | @Test 20 | public void test3() { 21 | assertTrue(SelfDescribingNumbers.isSelfDescribing(21200)); 22 | } 23 | 24 | @Test 25 | public void test4() { 26 | assertTrue(SelfDescribingNumbers.isSelfDescribing(3211000)); 27 | } 28 | 29 | @Test 30 | public void test5() { 31 | assertTrue(SelfDescribingNumbers.isSelfDescribing(42101000)); 32 | } 33 | 34 | @Test 35 | public void test6() { 36 | assertFalse(SelfDescribingNumbers.isSelfDescribing(55)); 37 | } 38 | 39 | @Test 40 | public void test7() { 41 | assertFalse(SelfDescribingNumbers.isSelfDescribing(1456)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /challenges/seriesSum/seriesSum.md: -------------------------------------------------------------------------------- 1 | ## SeriesSum 2 | Problem originally found on [codewars](http://www.codewars.com/) 3 | 4 | Your task is to write a function which returns the sum of following series up to nth term(parameter). 5 | 6 | `Series: 1 + 1/4 + 1/7 + 1/10 + 1/13 + 1/16 +...` 7 | -------------------------------------------------------------------------------- /challenges/seriesSum/solutions/Solution2.js: -------------------------------------------------------------------------------- 1 | //javascript solution 2 | 3 | function SeriesSum(n) { 4 | var seriesSum = 0; 5 | while (n > 0) { 6 | seriesSum += 1/(4+((n-2)*3)) 7 | n-- 8 | } 9 | return (seriesSum).toFixed(2) 10 | } 11 | 12 | // javascript tests 13 | console.log(SeriesSum(1) === "1.00") 14 | console.log(SeriesSum(2) === "1.25") 15 | console.log(SeriesSum(3) === "1.39") 16 | console.log(SeriesSum(4) === "1.49") 17 | 18 | //Recursive javascript solution 19 | 20 | function SeriesSum(n) { 21 | if(n === 0) return 1; 22 | return ( (1 /(3*n + 1) ) + SeriesSum(n - 1) ); 23 | } 24 | 25 | // submitted by https://github.com/kikoorikoo 26 | -------------------------------------------------------------------------------- /challenges/seriesSum/solutions/Solution2.py: -------------------------------------------------------------------------------- 1 | def series_sum(n): 2 | total = 0 3 | for num in range(0, n): 4 | total += 1/(num*3.0 + 1) 5 | 6 | return total 7 | #print series_sum(1) 8 | #print series_sum(4) 9 | 10 | #submitted by https://github.com/jungjung917 11 | -------------------------------------------------------------------------------- /challenges/seriesSum/solutions/Solution2.rb: -------------------------------------------------------------------------------- 1 | def sum_series(n) 2 | n.times.map { |i| 1/(i*3+1).to_f}.reduce(:+).round(3) 3 | end 4 | 5 | # Tests 6 | 7 | puts sum_series(1)==1 8 | puts sum_series(2)==1.25 9 | puts sum_series(3)==1.393 10 | puts sum_series(4)==1.493 11 | puts sum_series(5)==1.57 12 | 13 | #submitted by https://github.com/leahgoldberg 14 | -------------------------------------------------------------------------------- /challenges/seriesSum/solutions/Solution3.js: -------------------------------------------------------------------------------- 1 | function series(n) { 2 | let total = 0; 3 | for (let i=1; i<=n; i++) { 4 | total += 1/(((i-1)*3)+1); 5 | } 6 | return total; 7 | } 8 | 9 | series(5) 10 | 11 | 12 | //solved 11/29 @ WWC @ Betterment meetup 13 | -------------------------------------------------------------------------------- /challenges/seriesSum/solutions/objcSeriesSum.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SeriesSum 4 | // 5 | // Created by Julianne on 7/17/16. 6 | // Copyright © 2016 Julianne Goyena. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | void sumOfSeries(int n) { 12 | float sum = 0.000000; 13 | for (int i = 1; i <= n; i++) { 14 | sum += (1.0000000 / (4 + (i - 2) * 3)); 15 | } 16 | 17 | NSLog(@"%f", sum); 18 | } 19 | 20 | int main(int argc, const char * argv[]) { 21 | @autoreleasepool { 22 | 23 | // Your task is to write a function which returns the sum of following series up to nth term(parameter). 24 | // Series: 1 + 1/4 + 1/7 + 1/10 + 1/13 + 1/16 +... 25 | 26 | sumOfSeries(1); 27 | sumOfSeries(2); 28 | sumOfSeries(3); 29 | sumOfSeries(4); 30 | sumOfSeries(5); 31 | sumOfSeries(6); 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /challenges/sevenSidedDice/sevenSidedDice.md: -------------------------------------------------------------------------------- 1 | # Seven-sided dice 2 | 3 | ## Problem 4 | 5 | Given an existing function `dice5` that is an equal-probability generator of one of the integers 1 to 5, create a function `dice7` that generates a pseudo-random integer from 1 to 7 in equal probability using only `dice5` as a source of random numbers. 6 | 7 | Bonus points: check the distribution by running your function a million times. 8 | 9 | [Source](http://rosettacode.org/wiki/Seven-sided_dice_from_five-sided_dice) 10 | -------------------------------------------------------------------------------- /challenges/sharePrice/sharePrice.md: -------------------------------------------------------------------------------- 1 | ## Share price 2 | Problem originally found on [codewars](http://www.codewars.com/) 3 | 4 | Imagine after your first pay check from your first job as an amazing lady programmer, you invested a portion of it into some stock market shares. Now imagine that a few years later you want to see how much those shares are worth but for some bizarre reason you wanted to figure it out yourself with a list of days and the percentage change of the value of those share. How could you go about it? 5 | -------------------------------------------------------------------------------- /challenges/sharePrice/solutions/sharePrice.js: -------------------------------------------------------------------------------- 1 | // Javascript solution 2 | var sharePrice = function(invested, changes) { 3 | var finalPrice = invested; 4 | changes.forEach( function(percent) { 5 | var change = finalPrice * percent * .01; 6 | finalPrice += change; 7 | }); 8 | return finalPrice; 9 | }; 10 | 11 | // ES6 solution 12 | // sharePrice (invested, changes) => { 13 | // var finalPrice = invested; 14 | // changes.forEach((percent) => { 15 | // var change = finalPrice * percent * .01; 16 | // finalPrice += change; 17 | // }) 18 | // return finalPrice 19 | // } 20 | 21 | //Tests 22 | 23 | console.log(sharePrice(100, [])===100); 24 | console.log(sharePrice(100, [-50, 50]) === 75); 25 | console.log(sharePrice(100, [-50, 100]) === 100); 26 | console.log(sharePrice(100, [-20, 30]) === 104); 27 | -------------------------------------------------------------------------------- /challenges/sieveOfEratosthenes/sieveOfEratosthenes.md: -------------------------------------------------------------------------------- 1 | ## The Sieve of Eratosthenes 2 | 3 | Write a program that uses the Sieve of Eratosthenes to find the sum of all the primes from 2 up to a given number 4 | 5 | ### Background 6 | 7 | The Sieve of Eratosthenes is a simple, ancient algorithm for finding all prime numbers up to any given limit. It does so by iteratively marking as composite (i.e. not prime) the multiples of each prime, starting with the multiples of 2. 8 | Create your range, starting at two and continuing up to and including the given limit. (i.e. [2, limit]) 9 | The algorithm consists of repeating the following over and over: 10 | take the next available unmarked number in your list (it is prime) 11 | mark all the multiples of that number (they are not prime) 12 | Repeat until you have processed each number in your range. 13 | When the algorithm terminates, all the numbers in the list that have not been marked are prime. 14 | -------------------------------------------------------------------------------- /challenges/sieveOfEratosthenes/solutions/sieveOfErathosthenes.rb: -------------------------------------------------------------------------------- 1 | def find_primes(limit) 2 | numbers = (2..limit).to_a 3 | prime = 2 4 | index = 0 5 | while prime <= limit/2 6 | (numbers[(index + 1 )]..limit).to_a.each do |number| 7 | if number % prime == 0 8 | numbers -= [number] 9 | end 10 | end 11 | index += 1 12 | prime = numbers[index] 13 | end 14 | numbers 15 | end 16 | 17 | puts find_primes(5) == [2,3,5] 18 | puts find_primes(10) == [2,3,5,7] 19 | 20 | def sum_primes(primes) 21 | sum = 0 22 | primes.each do |number| 23 | sum += number 24 | end 25 | sum 26 | end 27 | 28 | puts sum_primes(find_primes(5)) == 10 29 | -------------------------------------------------------------------------------- /challenges/sieveOfEratosthenes/solutions/sieveOfEratosthenes.js: -------------------------------------------------------------------------------- 1 | function Erat(max){ 2 | var primes = [] 3 | for (i=0; i< max; i++){ 4 | primes.push(true) 5 | } 6 | for(var x=2; x "one hundred fifty-four" 10 | 11 | f(9000) 12 | // => "nine thousand" 13 | ``` 14 | 15 | [Source](http://rosettacode.org/wiki/Number_names) 16 | -------------------------------------------------------------------------------- /challenges/string2Int/string2Int.md: -------------------------------------------------------------------------------- 1 | ## Interconvert strings and integers 2 | 3 | A string is a sequence of characters. 4 | A string may encode an integer, e.g., "-987" encodes 987. 5 | Implement methods that take a string representing an integer 6 | and return the corresponding integer, and vice versa. 7 | Your code should handle negative integers. 8 | You cannot use library fucntions like stoi in C++ and parseInt in Java. 9 | 10 | /************************************ 11 | Aksana Kuzmitskaya 12 | aksana.kuzmitskaya@gmail.com 13 | ************************************/ 14 | -------------------------------------------------------------------------------- /challenges/stringCount/stringCount.md: -------------------------------------------------------------------------------- 1 | Given a string and a non-empty substring, compute recursively the number of times that substring appears in the string, without the sub strings overlapping. 2 | 3 | strCount("catcowcat", "cat") → 2 4 | strCount("catcowcat", "cow") → 1 5 | strCount("catcowcat", "dog") → 0 6 | 7 | 8 | Can you solve this iteratively and recursively? 9 | -------------------------------------------------------------------------------- /challenges/stripWhitespace/stripWhitespace.md: -------------------------------------------------------------------------------- 1 | ## Strip whitespace 2 | 3 | Write a function to strip leading and trailing whitespace from a string. 4 | 5 | ### Example 6 | 7 | ```ruby 8 | f(" adopt a dog!\n\n\n") 9 | # => 'adopt a dog!' 10 | ``` 11 | 12 | [Source](http://rosettacode.org/wiki/Strip_whitespace_from_a_string/Top_and_tail) 13 | -------------------------------------------------------------------------------- /challenges/sudoku/sudoku.md: -------------------------------------------------------------------------------- 1 | ## Sudoku Checker 2 | 3 | How could you determine if a 9 by 9 [sudoku](https://en.wikipedia.org/wiki/Sudoku) 4 | grid had been solved? Create a function which takes in a sudoku board and returns "Finished!" 5 | if the board is valid and "Try again!" if the board is incomplete or has duplicates. 6 | 7 | Originally found on Code Wars 8 | -------------------------------------------------------------------------------- /challenges/sumPairs/solutions/Ruby-optimized.rb: -------------------------------------------------------------------------------- 1 | def sum_pairs(ary, total) 2 | 3 | previous_values = {} 4 | 5 | ary.each do |value| 6 | complement = total - value 7 | 8 | if previous_values[complement] 9 | return [complement, value] 10 | else 11 | previous_values[value] = true 12 | end 13 | end 14 | return nil 15 | end 16 | 17 | p sum_pairs([11, 3, 7, 5], 10) 18 | 19 | p sum_pairs([4, 3, 2, 3, 4], 6) 20 | 21 | p sum_pairs([0, 0, -2, 3], 2) 22 | 23 | p sum_pairs([10, 5, 2, 3, 7, 5], 10) 24 | 25 | big_ary = (1..10_000_000).map{rand(-10..10)} 26 | 27 | p sum_pairs(big_ary, 15) 28 | 29 | p sum_pairs(big_ary, 21) 30 | -------------------------------------------------------------------------------- /challenges/sumPairs/solutions/sumPairs.js: -------------------------------------------------------------------------------- 1 | const sumPairs = (arr, tgt) => { 2 | const hash = {} 3 | for (let i=0, len=arr.length; i 2 | Given a number n, generate all distinct ways to write n as the sum of positive integers. For example, with n = 4, the options are 4, 3 + 1, 2 + 2, 2 + 1 + 1, and 1 + 1 + 1 + 1. (Note that 3+1 and 1+3 are considered the same and thus only 3+1 is a part of the result). 3 | 4 | You can output your results as an array of strings (["4","3+1", "2+2", "2+1+1", "1+1+1+1"]). 5 | 6 | submitted by [seemaullal](https://github.com/seemaullal) 7 | -------------------------------------------------------------------------------- /challenges/ticTacToe/ticTacToe.md: -------------------------------------------------------------------------------- 1 | # Tic-Tac-Toe 2 | 3 | ## Problem 4 | 5 | Determine if a tic-tac-toe board, represented by a 3x3 multidimensional array, has a winner. 6 | 7 | ## Examples 8 | 9 | ``` 10 | Input: 11 | [ 12 | [X, O, O], 13 | [X, O, O], 14 | [O, X, X] 15 | ] 16 | 17 | Output: 18 | Winner: O 19 | 20 | Input: 21 | [ 22 | [O, X, O], 23 | [X, O, O], 24 | [X, O, X] 25 | ] 26 | 27 | Output: 28 | Winner: none 29 | ``` 30 | -------------------------------------------------------------------------------- /challenges/timeConversion/solutions/Solution1.js: -------------------------------------------------------------------------------- 1 | // javascript solution 2 | function convertTime(input) { 3 | 4 | var hours, amPM; 5 | 6 | hours = parseInt(input.slice(0, 2)); 7 | amPM = input.slice(-2); 8 | 9 | if (amPM === 'PM') { 10 | if (hours < 12) { 11 | hours = hours + 12; 12 | } 13 | } else { 14 | if (hours === 12) { 15 | hours = '00'; 16 | } else { 17 | hours = hours > 10 ? hours : '0' + hours; 18 | } 19 | } 20 | 21 | return (hours + input.slice(2, -2)); 22 | } 23 | 24 | console.log(convertTime('12:00:00PM')); // return 12:00:00 25 | console.log(convertTime('06:59:59PM')); // return 18:59:59 26 | console.log(convertTime('12:00:00AM')); // return 00:00:00 27 | console.log(convertTime('04:59:59AM')); // return 04:59:59 28 | console.log(convertTime('11:00:00AM')); // return 11:00:00 29 | 30 | //submitted by https://github.com/lei-clearsky 31 | -------------------------------------------------------------------------------- /challenges/timeConversion/solutions/convert_time.py: -------------------------------------------------------------------------------- 1 | #Python program to convert time 2 | #Author: Ruth Naebeck 3 | 4 | def convert_time(sTime): 5 | sPM = "PM"; 6 | sColon = ":"; 7 | 8 | if sTime == "12:00:00AM": 9 | print "00:00:00" 10 | elif sTime == "12:00:00PM": 11 | print "12:00:00" 12 | elif sTime.find(sPM) > -1: 13 | iTime = int(sTime[:sTime.find(sColon)]) + 12 14 | sMilitaryTime = str(iTime) + sTime[sTime.find(sColon):] 15 | print sMilitaryTime[:-2] 16 | else: 17 | print sTime[:-2] 18 | 19 | convert_time("05:00:00AM") 20 | convert_time("05:00:00PM") 21 | convert_time("12:00:00AM") 22 | convert_time("12:00:00PM") 23 | -------------------------------------------------------------------------------- /challenges/timeConversion/solutions/team_macj.js: -------------------------------------------------------------------------------- 1 | function convertTo24(originalTime){ 2 | var isAM = originalTime.toUpperCase().indexOf("AM") >= 0; 3 | 4 | var timeOnly = originalTime.replace(/[^\d:]/g, ""); 5 | 6 | var timeArray = timeOnly.split(":"); 7 | var hourNumeric = parseInt(timeArray[0]); 8 | hourNumeric = hourNumeric % 12; 9 | 10 | if(!isAM){ 11 | hourNumeric += 12 12 | } 13 | 14 | if(hourNumeric < 10){ 15 | timeArray[0] = "0" + hourNumeric; 16 | }else{ 17 | timeArray[0] = hourNumeric; 18 | } 19 | 20 | var newTime = timeArray.join(":"); 21 | 22 | console.log("Original Time:", originalTime, ", 24hr Time:", newTime); 23 | } 24 | 25 | //convertTo24("12:00:30AM"); 26 | //convertTo24("12:40:55PM"); 27 | //convertTo24("03:22:40AM"); 28 | //convertTo24("08:45:20PM"); 29 | -------------------------------------------------------------------------------- /challenges/timeConversion/solutions/testing/README.md: -------------------------------------------------------------------------------- 1 | # Javascript Tests 2 | ### Setup 3 | - npm install -g mocha 4 | - npm install chai 5 | - To run from command line ```mocha test/time_conversion_test.js``` while in testing directory 6 | 7 | # Ruby Tests 8 | - To run from command line ```ruby spec/time_conversion_spec.rb --verbose``` while in testing directory 9 | 10 | -------------------------------------------------------------------------------- /challenges/timeConversion/solutions/time_conversion.js: -------------------------------------------------------------------------------- 1 | // Time converion 2 | function timeConversion(time) { 3 | var re = /^([0][1-9]|[1][0-2]):[0-5][0-9]:[0-5][0-9](AM|PM)$/; 4 | if(time.length !== 10 || time.match(re) == null) { 5 | return 'Please enter a valid time in hh:mm:ssA format.' 6 | } 7 | 8 | var meridian = time.match(/AM/) ? 'AM' : 'PM'; 9 | var hour = parseInt(time.substr(0,2)); 10 | 11 | if(meridian == 'PM') { 12 | if(hour < 12) { 13 | hour = (hour + 12).toString(); 14 | } 15 | } else if(meridian == 'AM') { 16 | if(hour === 12) { 17 | hour = '00'; 18 | } else if((hour = hour.toString()).length < 2) { 19 | hour = '0' + hour; 20 | } 21 | } 22 | 23 | return hour + time.substr(2, 6); 24 | } 25 | module.exports = timeConversion; 26 | -------------------------------------------------------------------------------- /challenges/timeConversion/solutions/time_conversion.rb: -------------------------------------------------------------------------------- 1 | def time_conversion(time) 2 | re = /^([0][1-9]|[1][0-2]):[0-5][0-9]:[0-5][0-9](AM|PM)$/ 3 | if (time.length != 10 || (re =~ time).nil?) 4 | return 'Please enter a valid time in hh:mm:ssA format.' 5 | end 6 | 7 | meridian = /PM/ =~ time 8 | hour = time[0, 2].to_i 9 | 10 | if meridian 11 | if hour < 12 12 | hour = "#{hour + 12}" 13 | end 14 | else 15 | if hour === 12 16 | hour = '00' 17 | elsif hour < 10 18 | hour = "0#{hour}" 19 | end 20 | end 21 | 22 | "#{hour}#{time[2, 6]}" 23 | end 24 | -------------------------------------------------------------------------------- /challenges/timeConversion/timeConversion.md: -------------------------------------------------------------------------------- 1 | ## Time Conversion 2 | Problem found on [HackerRank](http://www.hackerrank.com) 3 | 4 | You are given time in AM/PM format. Can you convert this into a 24-hour format? 5 | 6 | Note: Midnight is 12:00:00AM or 00:00:00. Noon is 12:00:00PM. 7 | 8 | submitted by https://github.com/lei-clearsky 9 | -------------------------------------------------------------------------------- /challenges/towersOfHanoi/solutions/towersOfHanoi.js: -------------------------------------------------------------------------------- 1 | function move(n, a, b, c) { 2 | if (n > 0) { 3 | move(n-1, a, c, b); 4 | console.log("Move disk from " + a + " to " + c); 5 | move(n-1, b, a, c); 6 | } 7 | } 8 | move(4, "A", "B", "C"); 9 | -------------------------------------------------------------------------------- /challenges/towersOfHanoi/towersOfHanoi.md: -------------------------------------------------------------------------------- 1 | Solve the Towers of Hanoi problem: 2 | > The Tower of Hanoi (also called the Tower of Brahma or Lucas' Tower,[1] and sometimes pluralized) is a mathematical game or puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape. 3 | 4 | > The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules: 5 | 6 | > Only one disk can be moved at a time. 7 | Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack. 8 | No disk may be placed on top of a smaller disk. 9 | 10 | ~ [wikipedia](https://en.wikipedia.org/wiki/Tower_of_Hanoi) 11 | -------------------------------------------------------------------------------- /challenges/tr/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WomenWhoCodeNYC/Algorithms/69bd06b806826392b7d0d675fe6f9966d592f48c/challenges/tr/.DS_Store -------------------------------------------------------------------------------- /challenges/tr/solutions/tr.js: -------------------------------------------------------------------------------- 1 | function tr(from, to, str){ 2 | var obj = {}; 3 | var newString = ""; 4 | 5 | for(var i = 0; i < from.length; i++){ 6 | obj[from[i]]=to[i]; 7 | } 8 | for(var j = 0; j 2 | 3 | 4 | -------------------------------------------------------------------------------- /challenges/tr/solutions/tr_swift.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /challenges/tr/solutions/tr_swift.playground/playground.xcworkspace/xcuserdata/ericamillado.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WomenWhoCodeNYC/Algorithms/69bd06b806826392b7d0d675fe6f9966d592f48c/challenges/tr/solutions/tr_swift.playground/playground.xcworkspace/xcuserdata/ericamillado.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /challenges/tr/solutions/tr_translate.py: -------------------------------------------------------------------------------- 1 | #Python program tr (translate) 2 | #Author: Ruth Naebeck 3 | 4 | ###Normal Translate Function 5 | ##import string 6 | ## 7 | ##def tr(sInput): 8 | ## 9 | ## print sInput.translate(string.maketrans("abc", "123")) 10 | ## 11 | ##tr("dcba") 12 | 13 | #Translate without using built-in function 14 | def tr(sFrom, sTo, sStr): 15 | 16 | sReturn = "" 17 | 18 | for cStr in sStr: 19 | i = 0 20 | for cFrom in sFrom: 21 | if cStr == cFrom: 22 | bStr = True 23 | break 24 | else: 25 | bStr = False 26 | i = i + 1 27 | if bStr == True: 28 | sReturn = sReturn + sTo[i] 29 | else: 30 | sReturn = sReturn + cStr 31 | print sReturn 32 | 33 | tr("abc","123","dcba") #d321 34 | tr("abc","123","LOBSTER") #LOBSTER 35 | tr("123", "abc", "bad") #bad 36 | tr("1a","a1","aax11") #11xaa 37 | -------------------------------------------------------------------------------- /challenges/tr/tr.md: -------------------------------------------------------------------------------- 1 | tr 2 | = 3 | 4 | tr (translate or transliterate) is a common shell program used to replace certain characters in a string with others. It's probably installed in your shell. You can test it out: 5 | 6 | tr abc ABC << "d321" 20 | 21 | tr("abc","123","LOBSTER") => "LOBSTER" 22 | 23 | tr("123", "abc", "bad") => "bad" 24 | 25 | tr("1a","a1","aax11") => "11xaa" 26 | 27 | 28 | ``` 29 | 30 | Bonus points: 31 | 32 | Does your implementation modify *str* in-place, or does it create a new string? Modifying it in-place saves memory, but loses the content of the original string. Try writing an alternate implementation that works the other way. 33 | -------------------------------------------------------------------------------- /challenges/triangleInequality/solutions/TriangleInequality.java: -------------------------------------------------------------------------------- 1 | package wwc; 2 | 3 | /** 4 | * Given three edge lengths, check whether they could form a triangle. 5 | * This is true if no edge is longer than the other two added together. 6 | * 7 | * For example, 3 4 5 is a valid triangle, but 3 4 8 is not because 8 > 3 + 4. 8 | * 9 | *@author Cintia F. Kasziba 10 | */ 11 | public class TriangleInequality { 12 | 13 | public static void main(String... args) { 14 | System.out.println("Is (3, 4, 8) triangle? " + isTriangle(3, 4, 8)); //false 15 | System.out.println("Is (3, 4, 5) triangle? " + isTriangle(3, 4, 5)); //true 16 | System.out.println("Is (3, 4, 0) triangle? " + isTriangle(3, 4, 0)); //false 17 | System.out.println("Is (3, -1, 8) triangle? " + isTriangle(3, -1, 8)); //false 18 | } 19 | 20 | public static boolean isTriangle(int a, int b, int c) { 21 | return !(a <= 0 || b <= 0 || c <= 0) 22 | && (a < b + c && b < a + c && c < a + b); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /challenges/triangleInequality/solutions/swiftTriangleInequality.playground: -------------------------------------------------------------------------------- 1 | // github.com/iOess 2 | // Swift 3 3 | // 4 | // Given three edge lengths, check whether they could form a triangle. This is true if no edge is longer than the other two added together. For example, 3 4 5 is a valid triangle, but 3 4 8 is not because 8 > 3 + 4. 5 | 6 | func triangleInequality(edges: [Int]) { 7 | 8 | guard let max = edges.max() else {return} 9 | 10 | if max > edges.filter({$0 != max}).reduce(0, +) 11 | { 12 | print("Could NOT form a triangle") 13 | } 14 | else { 15 | print("Could form a triangle") 16 | } 17 | } 18 | 19 | triangleInequality(edges: [3,4,5]) // Could form a triangle 20 | triangleInequality(edges: [3,4,7]) // Could form a triangle 21 | triangleInequality(edges: [3,4,8]) // Could NOT form a triangle 22 | -------------------------------------------------------------------------------- /challenges/triangleInequality/solutions/triangleInequality.py: -------------------------------------------------------------------------------- 1 | # Author is github id: ddk376 2 | # Contributors : Python group in the January 17, 2017 meetup 3 | # Version: Python 3.5.2 4 | 5 | def triangleInequality(side1, side2, side3): 6 | """Given lengths of the sides of a triangle, determine where a valid triangle is formed""" 7 | 8 | if side1 + side2 < side3 or side2 + side3 < side1 or side3 + side1 < side2: 9 | print( "Not a valid Triangle") 10 | else: 11 | print( "Valid Triangle") 12 | 13 | 14 | if __name__ == "__main__": 15 | print("\nTesting triangleInequality........................") 16 | triangleInequality(3,4,5) 17 | triangleInequality(3,4,8) 18 | -------------------------------------------------------------------------------- /challenges/triangleInequality/triangleInequality.md: -------------------------------------------------------------------------------- 1 | Given three edge lengths, check whether they could form a triangle. This is true if no edge is longer than the other two added together. For example, 3 4 5 is a valid triangle, but 3 4 8 is not because 8 > 3 + 4. [source](http://golf.shinh.org/p.rb?Triangle+Inequality) 2 | -------------------------------------------------------------------------------- /challenges/tribonacci/solutions/tribonacci.rb: -------------------------------------------------------------------------------- 1 | def tribonnoci(sig, num) 2 | max_num = num-3 3 | (0...max_num).each do |i| 4 | sig << sig[i..i+2].reduce(:+) 5 | end 6 | sig 7 | end 8 | 9 | puts tribonnoci([0,1,1], 10) 10 | 11 | -------------------------------------------------------------------------------- /challenges/tribonacci/solutions/tribonacci_solution.rb: -------------------------------------------------------------------------------- 1 | def tribonacci(signature, nth) 2 | while signature.length < nth 3 | signature << signature[-3..-1].inject(:+) 4 | end 5 | signature 6 | end 7 | 8 | p tribonacci([1,1,1], 10) 9 | # [1, 1, 1, 3, 5, 9, 17, 31, 57, 105] 10 | 11 | p tribonacci([0,0,1], 10) 12 | # [0, 0, 1, 1, 2, 4, 7, 13, 24, 44] 13 | -------------------------------------------------------------------------------- /challenges/tribonacci/tribonacci.md: -------------------------------------------------------------------------------- 1 | Found on [Code Wars](http://www.codewars.com/kata/tribonacci-sequence/javascript) 2 | 3 | Similar to the Fibonacci Sequence, the "Tribonacci" sequence takes the sum of the 4 | previous 3 numbers to generate the next number. However unlike the Fibonacci sequence, 5 | Tribonacci takes a "signature" or starting array of numbers. Different signatures 6 | will generate different sequences. 7 | 8 | For example. If the starting signature was [1, 1, 1] the resulting sequence would be 9 | ``` 10 | [1,1,1,3,5,9,17,31,...] 11 | ``` 12 | but if the signature was [0,0,1] it would be 13 | ``` 14 | [0,0,1,1,2,4,7,13,24,...] 15 | ``` 16 | 17 | Write a function that takes as its argument a signature and an "N" and return the 18 | first n elements (including the signature) 19 | -------------------------------------------------------------------------------- /challenges/twoKeyKeyboard/twoKeyKeyboard.md: -------------------------------------------------------------------------------- 1 | # Two key keyboard 2 | 3 | ## Problem 4 | 5 | Initially, on a notepad program, only the 'A' is present. You can perform two operations on this notepad for each step: 6 | 7 | **Copy All:** You can copy all the characters present on the notepad (partial copy is not allowed). 8 | **Paste:** You can paste the characters which were copied last time. 9 | 10 | Given a number _n_ (between 1 and 1000, inclusive), you must get exactly _n_ 'A's on the notepad by performing the minimum number of steps permitted. Output the minimum number of steps to get _n_ 'A'. 11 | 12 | ## Example 13 | 14 | ``` 15 | Input: 3 16 | Output: 3 17 | Explanation: 18 | Intitally, we have one character 'A'. 19 | In step 1, we use the Copy All operation. 20 | In step 2, we use the Paste operation to get 'AA'. 21 | In step 3, we use the Paste operation again to get 'AAA'. 22 | ``` 23 | 24 | [Source](https://leetcode.com/problems/2-keys-keyboard/) 25 | -------------------------------------------------------------------------------- /challenges/twoSum/solutions/twoSum.py: -------------------------------------------------------------------------------- 1 | from collections import Counter 2 | def twoSum(nums, target): 3 | lookup = {} # Hash table for constant time lookup 4 | for i,num in enumerate(nums): 5 | if target - num in lookup: 6 | return [i,lookup[target-num]] 7 | lookup[num] = i 8 | return [] 9 | 10 | if __name__ == "__main__": 11 | print(twoSum([1,5,3,11,4,9],8)) 12 | -------------------------------------------------------------------------------- /challenges/twoSum/solutions/twoSum_02.py: -------------------------------------------------------------------------------- 1 | def twoSum(nums, target): 2 | """ Given a list of nums with only one pair whose sum is the target, 3 | it returns the pair's respectie indices. 4 | 5 | args: 6 | nums: a list of numbers in the set of real numbers, including numbers < 0 7 | target: a number in the set of real numbers which has 1 pair inside nums whose sum is equal to target 8 | returns: 9 | a tuple containing the indices of the numbers whose sum is the target 10 | """ 11 | for num in nums: 12 | if (target - num) in nums: 13 | return (nums.index(num), nums.index(target - num)) -------------------------------------------------------------------------------- /challenges/twoSum/solutions/two_sum.rb: -------------------------------------------------------------------------------- 1 | def two_sum(array, num) 2 | array.each_with_index do |current_num, index| 3 | num_to_search_for = num - current_num 4 | return index, array.index(num_to_search_for) if array.include? num_to_search_for 5 | end 6 | end 7 | 8 | # Tests 9 | 10 | # test_one = two_sum([2, 7, 11, 15], 9) 11 | # puts test_one == [0,1] 12 | 13 | # test_two = two_sum([2, 7, 11, 15], 17) 14 | # puts test_two == [0,3] -------------------------------------------------------------------------------- /challenges/twoSum/twoSum.md: -------------------------------------------------------------------------------- 1 | ### Two Sum 2 | 3 | Design a method that takes an array of positive integers and returns the indices of the two distinct integers in the array that sum up to a specific target value. 4 | 5 | **Notes**: 6 | - You may assume that each input would have exactly one solution. 7 | - Can you think of at least two solutions/algorithms to solve the problem: one that is space efficient and another that is time efficient? 8 | 9 | Example: 10 | Given nums = [2, 7, 11, 15], target = 9, 11 | 12 | Because nums[0] + nums[1] = 2 + 7 = 9, 13 | return [0, 1]. 14 | 15 | **Add on challenge**: Extend your solution so that it returns **all pairs** of indices that solve the problem. 16 | -------------------------------------------------------------------------------- /challenges/vowelSquare/vowelSquare.md: -------------------------------------------------------------------------------- 1 | # Vowel square 2 | 3 | ## Problem 4 | 5 | Write a function that takes a 2D matrix of some arbitrary size filled with letters from the 6 | alphabet, and determine if a 2x2 square composed entirely of vowels exists in the matrix. 7 | If a 2x2 square of vowels is found, the function should return **the top-left position 8 | (row-column) of the square.** 9 | 10 | If no 2x2 square of vowels exists, then return the string "not found." 11 | 12 | If there are multiple squares of vowels, return the one that is at the most top-left position 13 | in the whole matrix. The input matrix will at least be of size 2x2. 14 | 15 | 16 | For example, the array ['abcd', 'eikr', 'oufj'] looks like this: 17 | 18 | ``` 19 | a b c d 20 | e i k r 21 | o u f j 22 | ``` 23 | 24 | Within this matrix, there is a 2x2 square of vowels: the lower left corner that goes `'ei'` and `'ou'`. 25 | 26 | ## Example 27 | 28 | ```javascript 29 | f(['abcd', 'eikr', 'oufj']) 30 | // => '1-0' 31 | ``` 32 | 33 | [Source](https://www.coderbyte.com/editor/guest:Vowel%20Square:JavaScript) 34 | -------------------------------------------------------------------------------- /challenges/waysToCoverDistance/waysToCoverDistance.md: -------------------------------------------------------------------------------- 1 | # Count the number of ways to cover distance 2 | 3 | ## Problem 4 | Given a distance, count total number of ways to cover the distance with steps, leaps, and bounds! A step covers a distance of 1, a leap covers a distance of 2, and a bound covers a distance of 3. 5 | 6 | ## Examples 7 | 8 | ```javascript 9 | f(3) // How many ways can you cover a distance of 3? 10 | // => 4 11 | // step (1) + step (1) + step (1) 12 | // step (1) + leap (2) 13 | // leap (2) + step (1) 14 | // bound (3) 15 | 16 | f(4) 17 | // => 7 18 | ``` 19 | 20 | [Source](https://www.geeksforgeeks.org/count-number-of-ways-to-cover-a-distance/) 21 | -------------------------------------------------------------------------------- /challenges/wordSearch/wordSearch.md: -------------------------------------------------------------------------------- 1 | # Word Search 2 | 3 | ## Problem 4 | 5 | Given a 2D board and a word, find if the word exists in the grid. 6 | The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally 7 | or vertically neighboring. The same letter cell may not be used more than once. 8 | 9 | 10 | ## Example 11 | 12 | board = 13 | [ 14 | ['A','B','C','E'], 15 | ['S','F','C','S'], 16 | ['A','D','E','E'] 17 | ] 18 | 19 | Given word = "ABCCED", return true. 20 | Given word = "SEE", return true. 21 | Given word = "ABCB", return false. 22 | 23 | [Source](https://leetcode.com/problems/word-search/) 24 | -------------------------------------------------------------------------------- /images/branch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WomenWhoCodeNYC/Algorithms/69bd06b806826392b7d0d675fe6f9966d592f48c/images/branch.png -------------------------------------------------------------------------------- /images/clone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WomenWhoCodeNYC/Algorithms/69bd06b806826392b7d0d675fe6f9966d592f48c/images/clone.png -------------------------------------------------------------------------------- /images/clone2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WomenWhoCodeNYC/Algorithms/69bd06b806826392b7d0d675fe6f9966d592f48c/images/clone2.png -------------------------------------------------------------------------------- /images/commit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WomenWhoCodeNYC/Algorithms/69bd06b806826392b7d0d675fe6f9966d592f48c/images/commit.png -------------------------------------------------------------------------------- /images/first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WomenWhoCodeNYC/Algorithms/69bd06b806826392b7d0d675fe6f9966d592f48c/images/first.png -------------------------------------------------------------------------------- /images/pullRequest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WomenWhoCodeNYC/Algorithms/69bd06b806826392b7d0d675fe6f9966d592f48c/images/pullRequest.png -------------------------------------------------------------------------------- /images/pullRequest2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WomenWhoCodeNYC/Algorithms/69bd06b806826392b7d0d675fe6f9966d592f48c/images/pullRequest2.png -------------------------------------------------------------------------------- /past-events/April-16-2019.md: -------------------------------------------------------------------------------- 1 | # April 16 2019 2 | 3 | ### [Missing Number](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/missingNumber/missingNumber.md) 4 | ### [Two Sum](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/twoSum/twoSum.md) 5 | ### [Two Key Keyboard](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/twoKeyKeyboard/twoKeyKeyboard.md) 6 | ### [Remove Duplicate Letters II](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/removeDuplicatesInStringII/removeDuplicatesInStringII.md) 7 | ### [Merge Sorted Linked Lists](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/mergeSortedLinkedLists/mergeSortedLinkedLists.md) 8 | 9 | Some Women Who Code Reminders! 10 | * Be on the lookout for new problems to submit, it would be greatly appreciated! 🙏🙏🙏 11 | * But also submit solutions if you'd like! 12 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 13 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 14 | -------------------------------------------------------------------------------- /past-events/April-18-2018.md: -------------------------------------------------------------------------------- 1 | # April 18 2018 2 | ### [Largest Prime](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/largestPrime/largest_prime.md) 3 | ### [Lattice Paths](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/latticePaths/latticePaths.md) 4 | ### [Majority Element](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/majorityElement/majorityElement.md) 5 | ### [Matching Closing Parenthesis](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/matchingClosingParenthesis/matchingClosingParenthesis.md) 6 | ### [Max Consecutive Ones](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/maxConsecutiveOnes/maxConsecutiveOnes.md) 7 | 8 | 9 | Some Women Who Code Reminders! 10 | 11 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 12 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 13 | * SUBMIT NEW PROBLEMS! WE NEED YOUR HELP! 14 | -------------------------------------------------------------------------------- /past-events/April-19-2017.md: -------------------------------------------------------------------------------- 1 | # April 19 2017 2 | ### [CoinDenominations](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/coinDenominations/coinDenominations.md) 3 | ### [Second Largest in Binary Search Tree](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/2ndLargestInBST/2ndLargestInBST.md) 4 | ### [100Doors](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/100Doors/100Doors.md) 5 | ### [CaesarCipher](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/caesarCipher/caesarCipher.md) 6 | ### [Clique](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/clique/clique.md) 7 | -------------------------------------------------------------------------------- /past-events/April-28-2016.md: -------------------------------------------------------------------------------- 1 | # April 28 2016 2 | ### Problem 1 - [Tribonacci](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/tribonacci/tribonacci.md) 3 | ### Problem 2 - [Credit Card Mask](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/creditCardMask/ccMask.md) 4 | ### Problem 3 - [CompareTwoStrings](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/CompareTwoStrings/CompareTwoStringsRepresentedAsLinkedLists.md) 5 | ### Problem 4 - [Sudoku](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/sudoku/sudoku.md) 6 | ### Problem 5 - [Edge Tree](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/edgeTree/edgeTree.md) 7 | ### Problem 6 - [medianMaintenance](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/medianMaintenance/medianMaintenance.md) 8 | -------------------------------------------------------------------------------- /past-events/August-11-2016.md: -------------------------------------------------------------------------------- 1 | # August 11 2016 2 | ### Problem 1 - [Range Print Out](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/range/range.md) 3 | ### Problem 2 - [Greatest Common Denominator](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/gcd/gcd.md) 4 | ### Problem 3 - [Factorial](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/factorial/factorial.md) 5 | ### Problem 4 - [palindrome](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/palindrome/palindrome.md) 6 | ### Problem 5 - [stringCount](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/stringCount/stringCount.md) 7 | ### Problem 6 - [investment](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/investment/investment.md) 8 | -------------------------------------------------------------------------------- /past-events/August-19-2015.md: -------------------------------------------------------------------------------- 1 | ## August 19 2015 2 | 3 | ### Problem 1 - [double](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/double/double.md) 4 | ### Problem 2 - [getFileExtension](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/getFileExtension/getFileExtension.md) 5 | ### Problem 3 - [repeatify](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/repeatify/repeatify.md) 6 | ### Problem 4 - [palindrome](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/palindrome/palindrome.md) 7 | ### Problem 5 - [permutate](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/permutate/permutate.md) 8 | ### Problem 6 - [reverse](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/reverse/reverse.md) 9 | -------------------------------------------------------------------------------- /past-events/August-21-2018.md: -------------------------------------------------------------------------------- 1 | # August 21 2018 2 | ### [Convert Time](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/convertTime/convertTime.md) 3 | ### [Maximize Stock Profit](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/maximizeStockProfit/maximizeStockProfit.md) 4 | ### [Fibonacci Checker](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/fibonacciChecker/fibonacciChecker.md) 5 | ### [Quick Sort](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/quickSort/quickSort.md) 6 | ### [Edge Tree](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/edgeTree/edgeTree.md) 7 | 8 | Some Women Who Code Reminders! 9 | * [Upcoming Events](https://www.meetup.com/WomenWhoCodeNYC) 10 | * August 30: [Who's Afraid of Machine Learning?](https://www.meetup.com/WomenWhoCodeNYC/events/253879892/) 11 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 12 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 13 | * SUBMIT NEW PROBLEMS! WE (STILL) NEED YOUR HELP! 14 | -------------------------------------------------------------------------------- /past-events/December-19-2018.md: -------------------------------------------------------------------------------- 1 | # December 19 2018 2 | ### [Range](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/range/range.md) 3 | ### [Power Set](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/powerSet/powerSet.md) 4 | ### [Clock Hands](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/clockHands/clockHands.md) 5 | ### [Insertion Sort](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/insertionSort/insertionSort.md) 6 | ### [Vowel Square](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/vowelSquare/vowelSquare.md) 7 | 8 | Some Women Who Code Reminders! 9 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 10 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 11 | * Be on the lookout for new problems to submit 🙏🙏🙏 12 | -------------------------------------------------------------------------------- /past-events/February-16-2017.md: -------------------------------------------------------------------------------- 1 | # February 16 2017 2 | ### [Tribonacci](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/tribonacci/tribonacci.md) 3 | ### [Roman Numerals](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/roman-numerals/roman-numerals.md) 4 | ### [Largest Prime](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/largestPrime/largest_prime.md) 5 | ### [Lattice Paths](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/latticePaths/latticePaths.md) 6 | ### [Partition Linked List](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/partitionLinkedList/partitionLinkedList.md) 7 | 8 | 9 | ![Happy Galentine's Day](https://media.giphy.com/media/l3q2tpNX0icJxe87K/source.gif) 10 | ![Happy Galentine's Day pt2](https://media.giphy.com/media/qjXuMQ4TTaDSg/giphy.gif) 11 | 12 | ....uhhh, Leslie, are you sure you don't mean Feb 16 aka WWCNYC's Algorithm's night is the best day of the year? 13 | -------------------------------------------------------------------------------- /past-events/February-18-2016.md: -------------------------------------------------------------------------------- 1 | ## February 18 2015 2 | 3 | ### Problem 1 - [caesarCipher](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/caesarCipher/caesarCipher.md) 4 | ### Problem 2 - [medianCollection](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/medianCollection/medianCollection.md) 5 | ### Problem 3 - [string2Int](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/string2Int/string2Int.md) 6 | ### Problem 4 - [reverseSublist](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/reverseSublist/reverseSublist.md) 7 | ### Problem 5 - [cyclicalLinkedList](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/cyclicalLinkedList/cyclicalLinkedList.md) 8 | -------------------------------------------------------------------------------- /past-events/February-19-2019.md: -------------------------------------------------------------------------------- 1 | # February 19 2019 2 | 3 | ### [Longest Common Prefix](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/longestCommonPrefix/longestCommonPrefix.md) 4 | ### [Roman Numerals](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/romanNumerals/romanNumerals.md) 5 | ### [Egg Boiler](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/eggBoiler/eggBoiler.md) 6 | ### [First Missing Positive](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/firstMissingPositive/firstMissingPositive.md) 7 | ### [Tribonacci](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/tribonacci/tribonacci.md) 8 | 9 | Some Women Who Code Reminders! 10 | * Be on the lookout for new problems to submit, it would be greatly appreciated! 🙏🙏🙏 11 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 12 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 13 | -------------------------------------------------------------------------------- /past-events/February-21-2018.md: -------------------------------------------------------------------------------- 1 | # February 21 2018 2 | ### [Pig Latin](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/pigLatin/pigLatin.md) 3 | ### [Array Pair Sum](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/arrayPairSum/arrayPairSum.md) 4 | ### [Remove Duplicate Characters in a String](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/removeDuplicatesInString/removeDuplicatesInString.md) 5 | ### [Tic-Tac-Toe](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/ticTacToe/ticTacToe.md) 6 | ### [Ways to Cover Distance](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/waysToCoverDistance/waysToCoverDistance.md) 7 | 8 | 9 | Some Women Who Code Reminders! 10 | 11 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 12 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 13 | -------------------------------------------------------------------------------- /past-events/January-15-2019.md: -------------------------------------------------------------------------------- 1 | # January 15 2018 2 | ### [Spell Number](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/spellNumber/spellNumber.md) 3 | ### [Strip Whitespace](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/stripWhitespace/stripWhitespace.md) 4 | ### [Cyclical Linked List](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/cyclicalLinkedList/cyclicalLinkedList.md) 5 | ### [Merge Sort](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/mergeSort/mergeSort.md) 6 | ### [Largest Prime](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/largestPrime/largestPrime.md) 7 | 8 | Some Women Who Code Reminders! 9 | * Be on the lookout for new problems to submit 🙏🙏🙏 10 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 11 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 12 | -------------------------------------------------------------------------------- /past-events/January-17-2017.md: -------------------------------------------------------------------------------- 1 | # January 17 2017 2 | ### Problem 1 - [Even Odd Letters](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/evenOddLetters/evenOddLetters.md) 3 | ### Problem 2 - [Rock Paper Scissors](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/rockPaperScissors/rockPaperScissors.md) 4 | ### Problem 3 - [Towers of Hanoi](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/towersOfHanoi/towersOfHanoi.md) 5 | ### Problem 4 - [Triangle Inequality](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/triangleInequality/triangleInequality.md) 6 | ### Problem 5 - [Primes in Base 10](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/primesBase10/primesBase10.md) 7 | -------------------------------------------------------------------------------- /past-events/January-17-2018.md: -------------------------------------------------------------------------------- 1 | # January 17 2018 2 | ### [Letter Capitalize](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/letterCapitalize/letterCapitalize.md) 3 | ### [Binary Search](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/binarySearch/binarySearch.md) 4 | ### [Self-Describing Numbers ](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/selfDescribingNumbers/selfDescribingNumbers.md) 5 | ### [Anagram Detection](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/anagramDetection/anagramDetection.md) 6 | ### [Longest Range](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/longestRange/longestRange.md) 7 | 8 | 9 | Some Women Who Code Reminders! 10 | 11 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 12 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 13 | -------------------------------------------------------------------------------- /past-events/July-16-2015.md: -------------------------------------------------------------------------------- 1 | ## July 16 2015 2 | 3 | ### Problem 1 - [removeVowels](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/removeVowels/removeVowels.md) 4 | ### Problem 2 - [2dArray](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/2dArray/2dArray.md) 5 | ### Problem 3 - [getMin](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/getMin/getMin.md) 6 | ### Problem 4 - [longestRange](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/longestRange/longestRange.md) 7 | ### Problem 5 - [dictionary](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/dictionary/dictionary.md) 8 | ### Problem 6 - [sumsOfN](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/sumsOfN/sumsOfN.md) 9 | -------------------------------------------------------------------------------- /past-events/July-16-2019.md: -------------------------------------------------------------------------------- 1 | 2 | # July 16 2019 3 | 4 | ### [First Duplicate](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/firstDuplicate/firstDuplicate.md) 5 | ### [Word Search](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/wordSearch/wordSearch.md) 6 | ### [Ugly Number](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/UglyNumber/UglyNumber.md) 7 | ### [Grumpy Bookstore Owner](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/grumpyBookstoreOwner/grumpyBookstoreOwner.md) 8 | ### [Is Tree Symmetric](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/isTreeSymmetric/isTreeSymmetric.md) 9 | 10 | Some Women Who Code Reminders! 11 | * Be on the lookout for new problems to submit, it would be greatly appreciated! 🙏🙏🙏 12 | * But also submit solutions if you'd like! Open a PR, be a contributor! 13 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 14 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 15 | -------------------------------------------------------------------------------- /past-events/July-17-2018.md: -------------------------------------------------------------------------------- 1 | # July 17 2018 2 | ### [Remove Vowels](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/removeVowels/removeVowels.md) 3 | ### [Array Pair Sum](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/arrayPairSum/arrayPairSum.md) 4 | ### [Partition Linked List](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/partitionLinkedList/partitionLinkedList.md) 5 | ### [Coin Denominations](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/coinDenominations/coinDenominations.md) 6 | ### [Triangle Inequality](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/triangleInequality/triangleInequality.md) 7 | 8 | Some Women Who Code Reminders! 9 | * [Upcoming Events](https://www.meetup.com/WomenWhoCodeNYC) 10 | * [Javascript Lightning Talks July 26](https://www.meetup.com/WomenWhoCodeNYC/events/251899481/) 11 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 12 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 13 | * SUBMIT NEW PROBLEMS! WE NEED YOUR HELP! 14 | -------------------------------------------------------------------------------- /past-events/July-20-2017.md: -------------------------------------------------------------------------------- 1 | # July 20 2017 2 | ### [Investment](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/investment/investment.md) 3 | ### [Insertion Sort](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/insertionSort/insertionSort.md) 4 | ### [Hamming Distance](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/hammingDistance/hammingDistance.md) 5 | ### [kth To Last Element](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/kthToLastElement/kthToLastElement.md) 6 | ### [Largest Palindromic Number](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/largestPalindromicNumber/largest_palindromic_number.md) 7 | 8 | 👶 Congrats to Paddy! 👶 9 | -------------------------------------------------------------------------------- /past-events/June-15-2016.md: -------------------------------------------------------------------------------- 1 | # June 15 2016 2 | * [Fibbonacci Sum](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/fibonacciSum/fibonacci_sum.md) 3 | * [Largest Palindromic Number](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/largestPalindromicNumber/largest_palindromic_number.md) 4 | * [Largest Prime](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/largestPrime/largest_prime.md) 5 | * [Roman Numerals](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/roman-numerals/roman-numerals.md) 6 | * [Sum Square Difference](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/sumSquareDifference/sum_square_difference.md) 7 | * [Secret Message](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/SecretMessage/SecretMessage.md) 8 | -------------------------------------------------------------------------------- /past-events/June-18.md: -------------------------------------------------------------------------------- 1 | 2 | # June 18 2019 3 | 4 | ### [Range Sum Query](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/RangeSumQuery/RangeSumQuery.md) 5 | ### [3 Sum CLosest](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/3SumCLosest/3SumClosest.md) 6 | ### [Minimum rotations](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/minimumRotation/minimumRotation.md) 7 | ### [Smallest Subarray](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/smallestSubarray/smallestSubarray.md) 8 | ### [Validate IP Address](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/validateIP/validateIP.md) 9 | 10 | Some Women Who Code Reminders! 11 | * Be on the lookout for new problems to submit, it would be greatly appreciated! 🙏🙏🙏 12 | * But also submit solutions if you'd like! Open a PR, be a contributor! 13 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 14 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 15 | -------------------------------------------------------------------------------- /past-events/June-19-2018.md: -------------------------------------------------------------------------------- 1 | # June 19 2018 2 | ### [Get File Extension](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/getFileExtension/getFileExtension.md) 3 | ### [Credit Card Mask](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/creditCardMask/ccMask.md) 4 | ### [Bubble Sort](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/bubbleSort/bubbleSort.md) 5 | ### [Power of Two](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/powerOfTwo/powerOfTwo.md) 6 | ### [Median Maintenance](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/medianMaintenance/medianMaintenance.md) 7 | 8 | Some Women Who Code Reminders! 9 | 10 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 11 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 12 | * SUBMIT NEW PROBLEMS! WE NEED YOUR HELP! 13 | -------------------------------------------------------------------------------- /past-events/June-21-2017.md: -------------------------------------------------------------------------------- 1 | # June 21 2017 2 | ### [matchingClosingParenthesis](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/matchingClosingParenthesis/matchingClosingParenthesis.md) 3 | ### [evenOddLetters](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/evenOddLetters/evenOddLetters.md) 4 | ### [factorial](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/factorial/factorial.md) 5 | ### [fibonacciSum](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/fibonacciSum/fibonacci_sum.md) 6 | ### [getMin](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/getMin/getMin.md) 7 | -------------------------------------------------------------------------------- /past-events/March-15-2017.md: -------------------------------------------------------------------------------- 1 | # March 15 2017 2 | ### [Triangle Inequality](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/triangleInequality/triangleInequality.md) 3 | ### [Sudoku](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/sudoku/sudoku.md) 4 | ### [Sum Square Difference](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/sumSquareDifference/sum_square_difference.md) 5 | ### [Sums of N](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/sumsOfN/sumsOfN.md) 6 | ### [Sum Pairs](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/sumPairs/sumPairs.md) 7 | -------------------------------------------------------------------------------- /past-events/March-19-2019.md: -------------------------------------------------------------------------------- 1 | # March 19 2019 2 | 3 | ### [Divisible by Both](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/divisibleByBoth/divisibleByBoth.md) 4 | ### [Minimum Index Sum](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/minimumIndexSum/minimumIndexSum.md) 5 | ### [Selection Sort](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/selectionSort/selectionSort.md) 6 | ### [Max Increase to Keep City Skyline](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/maxIncreaseToKeepCitySkyline/maxIncreaseToKeepCitySkyline.md) 7 | ### [Unique Paths](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/uniquePaths/uniquePaths.md) 8 | 9 | Some Women Who Code Reminders! 10 | * Be on the lookout for new problems to submit, it would be greatly appreciated! 🙏🙏🙏 11 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 12 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 13 | -------------------------------------------------------------------------------- /past-events/May-17-2018.md: -------------------------------------------------------------------------------- 1 | # May 17 2018 2 | ### [Repeatify](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/repeatify/repeatify.md) 3 | ### [Bitonic Point](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/bitonicPoint/bitonicPoint.md) 4 | ### [Prime Sum](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/primeSum/primeSum.md) 5 | ### [Segregate Even and Odd Numbers](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/segregateEvenOdd/segregateEvenOdd.md) 6 | ### [Rotate Matrix](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/rotateMatrix/rotateMatrix.md) 7 | 8 | Some Women Who Code Reminders! 9 | 10 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 11 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 12 | * SUBMIT NEW PROBLEMS! WE NEED YOUR HELP! 13 | -------------------------------------------------------------------------------- /past-events/May-18-2016.md: -------------------------------------------------------------------------------- 1 | # May 18 2016 2 | ### Problem 1 - [timeConversion](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/timeConversion/timeConversion.md) 3 | ### Problem 2 - [tr](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/tr/tr.md) 4 | ### Problem 3 - [towersOfHanoi](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/towersOfHanoi/towersOfHanoi.md) 5 | ### Problem 4 - [sumPairs](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/sumPairs/sumPairs.md) 6 | ### Problem 5 - [sumsOfN](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/sumsOfN/sumsOfN.md) 7 | -------------------------------------------------------------------------------- /past-events/May-21-2019.md: -------------------------------------------------------------------------------- 1 | # May 21 2019 2 | 3 | ### [Letter Capitalize](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/letterCapitalize/letterCapitalize.md) 4 | ### [Search Insert Position](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/searchInsertPosition/searchInsertPosition.md) 5 | ### [Leaders in Array](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/leadersInArray/leadersInArray.md) 6 | ### [Can Plant Flowers](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/canPlantFlowers/canPlantFlowers.md) 7 | ### [Group Anagrams](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/groupAnagrams/groupAnagrams.md) 8 | 9 | Some Women Who Code Reminders! 10 | * Be on the lookout for new problems to submit, it would be greatly appreciated! 🙏🙏🙏 11 | * But also submit solutions if you'd like! Open a PR, be a contributor! 12 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 13 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 14 | -------------------------------------------------------------------------------- /past-events/November-16-2016.md: -------------------------------------------------------------------------------- 1 | # November 16 2016 2 | ### Problem 1 - [Bubble Sort](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/bubbleSort/bubbleSort.md) 3 | ### Problem 2 - [Selection Sort](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/selectionSort/selectionSort.md) 4 | ### Problem 3 - [Insertion Sort](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/insertionSort/insertionSort.md) 5 | ### Problem 4 - [Merge Sort](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/mergeSort/mergeSort.md) 6 | ### Problem 5 - [Quick Sort](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/quickSort/quickSort.md) 7 | -------------------------------------------------------------------------------- /past-events/November-18-2015.md: -------------------------------------------------------------------------------- 1 | ## November 18 2015 2 | 3 | ### Problem 1 - [timeConversion](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/timeConversion/timeConversion.md) 4 | ### Problem 2 - [pigLatin](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/pigLatin/pigLatin.md) 5 | ### Problem 3 - [powerOfTwo](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/powerOfTwo/powerOfTwo.md) 6 | ### Problem 4 - [kthToLastElement](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/kthToLastElement/kthToLastElement.md) 7 | ### Problem 5 - [balancedParentheses](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/balancedParentheses/balancedParentheses.md) 8 | ### Problem 6 - [quickSort](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/quickSort/quickSort.md) 9 | -------------------------------------------------------------------------------- /past-events/November-29-2017.md: -------------------------------------------------------------------------------- 1 | # November 29 2017 2 | ### [Series Sum](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/seriesSum/seriesSum.md) 3 | ### [Share Price](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/sharePrice/sharePrice.md) 4 | ### [Sieve of Eratosthenes ](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/sieveOfEratosthenes/sieveOfEratosthenes.md) 5 | ### [String 2 Int](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/string2Int/string2Int.md) 6 | ### [String Count](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/stringCount/stringCount.md) 7 | 8 | 9 | Some Women Who Code Reminders! 10 | 11 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 12 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 13 | -------------------------------------------------------------------------------- /past-events/October-13-2016.md: -------------------------------------------------------------------------------- 1 | 2 | ### Problem 1 - [timeConversion](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/timeConversion/timeConversion.md) 3 | 4 | ### Problem 2 - [balancedParanthesis](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/balancedParentheses/balancedParentheses.md) 5 | ### Problem 3 - [tr](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/tr/tr.md) 6 | 7 | ### Bonus Problems 8 | ### Problem 1 - [hammingDistance](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/hammingDistance/hammingDistance.md) 9 | ### Problem 2 - [edgeTree](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/edgeTree/edgeTree.md) 10 | ### Problem 3 - [clique](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/clique/clique.md) 11 | -------------------------------------------------------------------------------- /past-events/October-16-2018.md: -------------------------------------------------------------------------------- 1 | # October 16 2018 2 | ### [Range](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/range/range.md) 3 | ### [Factorial](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/factorial/factorial.md) 4 | ### [Best Shuffle](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/bestShuffle/bestShuffle.md) 5 | ### [I before E except after C](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/iBeforeEExceptAfterC/iBeforeEExceptAfterC.md) 6 | ### [Seven-Sided Dice](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/sevenSidedDice/sevenSidedDice.md) 7 | 8 | Some Women Who Code Reminders! 9 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 10 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 11 | * Be on the lookout for new problems to submit! 12 | -------------------------------------------------------------------------------- /past-events/October-18-2017.md: -------------------------------------------------------------------------------- 1 | # October 18 2017 2 | ### [Range](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/range/range.md) 3 | ### [Reverse Sublist](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/reverseSublist/reverseSublist.md) 4 | ### [Rock Paper Scissors ](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/rockPaperScissors/rockPaperScissors.md) 5 | ### [Roman Numerals](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/roman-numerals/roman-numerals.md) 6 | ### [Selection Sort](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/selectionSort/selectionSort.md) 7 | 8 | 9 | Some Women Who Code Reminders! 10 | 11 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 12 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 13 | -------------------------------------------------------------------------------- /past-events/October-22-2015.md: -------------------------------------------------------------------------------- 1 | ## October 22 2015 2 | 3 | ### Problem 1 - [eggBoiler](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/eggBoiler/eggBoiler.md) 4 | ### Problem 2 - [seriesSum](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/seriesSum/seriesSum.md) 5 | ### Problem 3 - [sharePrice](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/sharePrice/sharePrice.md) 6 | ### Problem 4 - [towersOfHanoi](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/towersOfHanoi/towersOfHanoi.md) 7 | ### Problem 5 - [rainWaterCollector](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/rainWaterCollector/rainWaterCollector.md) 8 | ### Problem 6 - [nthLeaf](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/nthLeaf/nthLeaf.md) 9 | -------------------------------------------------------------------------------- /past-events/September-15-2015.md: -------------------------------------------------------------------------------- 1 | ## September 15 2015 2 | 3 | ### Problem 1 - [fizzBuzz](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/fizzBuzz/fizzBuzz.md) 4 | ### Problem 2 - [100Doors](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/100Doors/100Doors.md) 5 | ### Problem 3 - [tr](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/tr/tr.md) 6 | ### Problem 4 - [sieveOfEratosthenes](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/sieveOfEratosthenes/sieveOfEratosthenes.md) 7 | ### Problem 5 - [sumPairs](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/sumPairs/sumPairs.md) 8 | ### Problem 6 - [latticePaths](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/latticePaths/latticePaths.md) 9 | -------------------------------------------------------------------------------- /past-events/September-18-2018.md: -------------------------------------------------------------------------------- 1 | # September 18 2018 2 | ### [Reverse](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/reverse/reverse.md) 3 | ### [tr](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/tr/tr.md) 4 | ### [Priority Queue](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/priorityQueue/priorityQueue.md) 5 | ### [Password Generator](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/passwordGenerator/passwordGenerator.md) 6 | ### [Perfect Numbers](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/perfectNumbers/perfectNumbers.md) 7 | 8 | Some Women Who Code Reminders! 9 | * [Upcoming Events](https://www.meetup.com/WomenWhoCodeNYC) 10 | * September 25: [Samsung Gear Workshop](https://www.meetup.com/WomenWhoCodeNYC/events/253565670/) 11 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 12 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 13 | * Be on the lookout for new problems to submit! 14 | -------------------------------------------------------------------------------- /past-events/September-20-2017.md: -------------------------------------------------------------------------------- 1 | # September 20 2017 2 | ### [Merge Sort](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/mergeSort/mergeSort.md) 3 | ### [Median Collection](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/medianCollection/medianCollection.md) 4 | ### [Product of Integers](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/productOfIntegers/productOfIntegers.md) 5 | ### [Longest Range](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/longestRange/longestRange.md) 6 | ### [Rain Water Collector](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/rainWaterCollector/rainWaterCollector.md) 7 | 8 | 9 | Some Women Who Code Reminders! 10 | 11 | * [Twitter!](https://twitter.com/WomenWhoCodeNYC) 12 | * [Women Who Code Mailing List](https://www.womenwhocode.com/) 13 | -------------------------------------------------------------------------------- /past-events/September-21-2016.md: -------------------------------------------------------------------------------- 1 | # September 21 2016 2 | 3 | ### Problem 1 - [caesarCipher](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/caesarCipher/caesarCipher.md) 4 | ### Problem 2 - [2dArray](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/2dArray/2dArray.md) 5 | ### Problem 3 - [getMin](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/getMin/getMin.md) 6 | ### Problem 4 - [kthToLastElement](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/kthToLastElement/kthToLastElement.md) 7 | ### Problem 5 - [balancedParentheses](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/balancedParentheses/balancedParentheses.md) 8 | ### Problem 6 - [investment](https://github.com/WomenWhoCodeNYC/Algorithms/blob/master/challenges/investment/investment.md) 9 | --------------------------------------------------------------------------------