-
-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add to existing code challenge (weeks 2 - 18) and pair programming folders (weeks 1 - 7) - Remove replit files - Fix linting issues, update dependencies: I removed node_modules and their caching, ran `npm update`, then had to do some npm auditing and force fixing, commit command runs linting without issue now
- Loading branch information
1 parent
0a826f2
commit 053aaa7
Showing
195 changed files
with
9,618 additions
and
3,685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.DS_STORE | ||
.DS_Store | ||
**.DS_STORE | ||
**.DS_Store | ||
.idea | ||
node_modules/ | ||
**node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# An anagram is a word formed by rearranging the letters of a different word using all the original letters exactly once. The function is given two strings: s - to search in, p - a p word. Find the starting indexes of anagrams of p among substrings of the given s. | ||
|
||
# Examples | ||
# findAnagrams("cbaebabacd", "abc") ➞ [0, 6] | ||
# // Anagrams: "cba", "bac" | ||
|
||
# findAnagrams("abab", "ab") ➞ [0, 1, 2] | ||
# // Anagrams: "ab", "ba", "ab" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Reverse the provided string and return the reversed string. For example, "hello" should become "olleh". | ||
|
||
# Examples | ||
# reverseString("hello") should return a string. | ||
# reverseString("hello") should return the string olleh. | ||
# reverseString("Howdy") should return the string ydwoH. | ||
# reverseString("Greetings from Earth") should return the string htraE morf sgniteerG. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
Implement a function which will convert the given boolean value into its string representation. | ||
Example: Example: | ||
Input: boolean false Input: boolean true | ||
Output: "false" Output: “true” | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? | ||
Example 1: | ||
Input: n = 2 | ||
Output: 2 | ||
Explanation: There are 2 ways to the top. | ||
1. 1 step + 1 step | ||
2. 2 steps | ||
Example 2: | ||
Input: n = 3 | ||
Output: 3 | ||
Explanation: There are 3 ways to the top. | ||
1. 1 step + 1 step + 1 step | ||
2. 1 step + 2 steps | ||
3. 2 steps + 1 step | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
Largest Swap | ||
Given a positive integer, find the largest number that could be generated by swapping only two digits at most once. | ||
Example 1: | ||
Input: 2736 | ||
Output : 7236 | ||
Explanation: | ||
If we swap the number 2 and the number | ||
7 then the generated number would be | ||
the largest number. | ||
Example 2: | ||
Input : 432 | ||
Output : 432 | ||
Explanation:Here, no swap is required. The given number is already the largest. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
Create a function that returns true if the first array can be nested inside the second and false otherwise. | ||
arr1 can be nested inside arr2 if: | ||
arr1's min is greater than arr2's min. | ||
arr1's max is less than arr2's max. | ||
Examples | ||
canNest([1, 2, 3, 4], [0, 6]) ➞ true | ||
canNest([3, 1], [4, 0]) ➞ true | ||
canNest([9, 9, 8], [8, 9]) ➞ false | ||
canNest([1, 2, 3, 4], [2, 3]) ➞ false | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
Create a function that takes an array of numbers between 1 and 10 (excluding one number) and returns the missing number. The array of numbers will be unsorted (not in order). Only one number will be missing. | ||
Examples | ||
missingNum([1, 2, 3, 4, 6, 7, 8, 9, 10]) ➞ 5 | ||
missingNum([7, 2, 3, 6, 5, 9, 1, 4, 8]) ➞ 10 | ||
missingNum([10, 5, 1, 2, 4, 6, 8, 3, 9]) ➞ 7 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Write a short program that prints each number from 1 to 100 on a new line. For numbers which are multiples of both 3 and 5, print "FizzBuzz" instead of the number. | ||
|
||
// Example 1: | ||
// Input: n = 3 | ||
// Output: [1 2 Fizz] | ||
|
||
// Example 2: | ||
// Input: n = 5 | ||
// Output: [1 2 Fizz 4 Buzz] | ||
|
||
// Example 3: | ||
// Input: n = 19 | ||
// Output: [1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Given a string, count the total number of vowels (a, e, i, o, u) in it. | ||
|
||
// Example 1: Example 2: | ||
// Input: ”abc de” Input: ”geeksforgeeks portal” | ||
// Output: 2 Output: 7 | ||
|
||
// Challenge: Think about how you can you solve this recursively after solving the problem. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Given an array arr[] of size N-1 with integers in the range of [1, N], the task is to find the missing number from the first N integers. There are no duplicates in the list. | ||
|
||
// Example 1: | ||
// Input: arr[] = | ||
// {1, 2, 4, 6, 3, 7, 8}, N = 8 | ||
// Output: 5 | ||
// Explanation: The missing number between 1 to 8 is 5 | ||
|
||
// Example 2: | ||
// Input: arr[] = {1, 2, 3, 5}, N = 5 | ||
// Output: 4 | ||
// Explanation: The missing number between 1 to 5 is 4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
The time has a format: hours:minutes. Both given hours and minutes will always have two digits, like 09:00. | ||
Make a regex to find time in the string: Breakfast at 09:00 in the room 123:456. In this task there’s no need to check time correctness yet, so 25:99 can also be a valid result. The regex should not match 123:456. Take your time with this problem. You will be learning how to use a new syntax: regular expression. | ||
Example 1 | ||
Input: I will have lunch at 12:00pm today at 925 Restaurant. | ||
Output: 12:00 | ||
Example 2 | ||
Input: Their daughter was born at 03:00am at 55 Melbourne Dr | ||
Output: 03:00 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
Halloween is the time of year when youth prepare for tricks or treats! Create a function that accepts a Date object and returns true if it's Halloween (October 31st) and false otherwise. Keep in mind JavaScript's Date month is 0 based, meaning October is the 9th month while January is 0. | ||
Examples: | ||
timeForTrickOrTreat(new Date(2013, 9, 31)) ➞ true | ||
timeForTrickorTreat(new Date(2013, 0, 23)) ➞ false | ||
timeForTrickorTreat(new Date(3000, 9, 31)) ➞ true | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a string s, return true if it is a palindrome, or false otherwise. | ||
Example 1: | ||
Input: s = "A man, a plan, a canal: Panama" | ||
Output: true | ||
Explanation: "amanaplanacanalpanama" is a palindrome. | ||
Example 2: | ||
Input: s = "race a car" | ||
Output: false | ||
Explanation: "raceacar" is not a palindrome. | ||
Example 3: | ||
Input: s = " " | ||
Output: true | ||
Explanation: s is an empty string "" after removing non-alphanumeric characters. | ||
Since an empty string reads the same forward and backward, it is a palindrome. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
Given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value. Return the largest lucky integer in the array. If there is no lucky integer return -1. | ||
Example 1: | ||
Input: arr = [2,2,3,4] | ||
Output: 2 | ||
Explanation: The only lucky | ||
number in the array is 2 because frequency[2] == 2. | ||
Example 2: | ||
Input: arr = [1,2,2,3,3,3] | ||
Output: 3 | ||
Explanation: 1, 2 and 3 are all lucky numbers, return the largest of them. | ||
Example 3: | ||
Input: arr = [2,2,2,3,3] | ||
Output: -1 | ||
Explanation: There are no lucky numbers in the array. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
Given a string s, return the longest palindromic substring in s. A substring is a contiguous non-empty sequence of characters within a string. | ||
Example 1: | ||
Input: s = "babad" | ||
Output: "bab" | ||
Explanation: "aba" is also a valid answer. | ||
Example 2: | ||
Input: s = "cbbd" | ||
Output: "bb" | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
A palindrome is a word or sentence that’s spelled the same way both forward and backward, ignoring punctuation, case, and spacing. Return true if the given string is a palindrome. Otherwise, return false. You should be able to pass strings with varying formats, such as “racecar”, “RaceCar”, and “race CAR” among others such as when the pattern includes special characters. Recall your new syntax: regular expression. | ||
Example 1: | ||
Input: “1 eye for of 1 eye.” | ||
Output: False | ||
Example 2: | ||
Input: “0_0 (: /-\ :) 0–0” | ||
Output: true | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
Create a function that returns an array of strings sorted by length in ascending order. Strings should have unique lengths (don't worry about comparing two strings with identical length). | ||
Return an empty array if the input array is empty. | ||
sortByLength(["a", "ccc", "dddd", "bb"]) ➞ ["a", "bb", "ccc", "dddd"] | ||
sortByLength(["apple", "pie", "shortcake"]) ➞ ["pie", "apple", "shortcake"] | ||
sortByLength(["may", "april", "september", "august"]) ➞ ["may", "april", "august", "september"] | ||
sortByLength([]) ➞ [] | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
This may look familiar, it was your problem from Week 12 - Friday. If you were OOO that Friday, so I’ve moved it here for you to solve. If you’ve submitted this during Week 12, share that link with me. | ||
Given an array of objects and the task is to convert the object keys to an array with the help of JavaScript. Convert an object into a new array which consists of all the keys in sequential order. | ||
Example: | ||
Input: let myObj = { | ||
name: "your name", | ||
address: "your address", | ||
age: "your Age", | ||
}; | ||
Output: ["name", "address", "age"] | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
Take an array and remove every second element from the array. Always keep the first element and start removing with the next element. There are no empty arrays. | ||
Example: | ||
Input: ["Keep", "Remove", "Keep", "Remove", "Keep", ...] | ||
Output: ["Keep", "Keep", "Keep", ...] | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
Your boss decided to save money by purchasing some cut-rate optical character recognition software for scanning in the text of old novels to your database. At first it seems to capture words okay, but you quickly notice that it throws in a lot of numbers at random places in the text. Your harried co-workers are looking to you for a solution to take this garbled text and remove all of the numbers. Your program will take in a string and clean out all numeric characters, and return a string with spacing and special characters ~#$%^&!@*():;"'.,? all intact. | ||
Example 1 Example 2 Example 3 | ||
Input: '! !' Input:'123456789' Input: 'This looks5 grea8t!' | ||
Output: '! !' Output: '' Output: 'This looks great!' | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
When coloring a striped pattern, you may start by coloring each square sequentially, meaning you spend time needing to switch coloring pencils. Create a function where given an array of colors cols, return how long it takes to color the whole pattern. It takes 1 second to switch between pencils. It takes 2 seconds to color a square. Only change coloring pencils if the next color is different to the color before it. Return a number in seconds. | ||
Examples: | ||
// There are 5 colors so it takes 2 seconds to color each one (2 x 5 = 10). | ||
// You need to switch the pencils 4 times and it takes 1 second to switch (1 x 4 = 4). | ||
// 10 + 4 = 14 | ||
color_pattern_times(["Red", "Blue", "Red", "Blue", "Red"]) ➞ 14 | ||
colorPatternTimes(["Blue"]) ➞ 2 | ||
colorPatternTimes(["Red", "Yellow", "Green", "Blue"]) ➞ 11 | ||
colorPatternTimes(["Blue", "Blue", "Blue", "Red", "Red", "Red"]) ➞ 13 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
Write a function that will check if two given characters are the same case. If either of the characters is not a letter, return -1. If both characters are the same case, return 1. If both characters are letters, but not the same case, return 0. | ||
Examples | ||
'a' and 'g' returns 1 'A' and 'C' returns 1 'b' and 'G' returns 0 | ||
'B' and 'g' returns 0 '0' and '?' returns -1 | ||
*/ |
18 changes: 18 additions & 0 deletions
18
code-challenges/Week_15/Remove-Trailing-and-Leading-Zeroes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
Create a function that takes in a number as a string n and returns the number without trailing and leading zeros. If you get a number with .0 on the end, return the integer value (e.g. return "4" rather than "4.0"). If the number is 0, 0.0, 000, 00.00, etc... return "0". Return a string. | ||
Trailing Zeros are the zeros after a decimal point which don't affect the value (e.g. the last three zeros in 3.4000 and 3.04000). | ||
Leading Zeros are the zeros before a whole number which don't affect the value (e.g. the first three zeros in 000234 and 000230). | ||
Examples | ||
removeLeadingTrailing("230.000") ➞ "230" | ||
removeLeadingTrailing("00402") ➞ "402" | ||
removeLeadingTrailing("03.1400") ➞ "3.14" | ||
removeLeadingTrailing("30") ➞ "30" | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
Given 2 strings, a and b, return a string of the form short+long+short, with the shorter string on the outside and the longer string on the inside. The strings will not be the same length, but they may be empty (zero length ). The length of string is not always the same as the number of characters | ||
Example 1 Example 2 | ||
Input: ("1", "22") Input: ("22", "1") | ||
Output: "1221" Output: "1221" | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
Create a function that takes an array of numbers between 1 and 10 (excluding one number) and returns the missing number. The array of numbers will be unsorted (not in order). Only one number will be missing. | ||
Examples | ||
missingNum([1, 2, 3, 4, 6, 7, 8, 9, 10]) ➞ 5 | ||
missingNum([7, 2, 3, 6, 5, 9, 1, 4, 8]) ➞ 10 | ||
missingNum([10, 5, 1, 2, 4, 6, 8, 3, 9]) ➞ 7 | ||
*/ |
10 changes: 10 additions & 0 deletions
10
code-challenges/Week_16/Format-Number-with-Commas-Separating-Thousands.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
Create a function that takes a number as an argument and returns a string formatted to separate thousands. You can expect a valid number for all test cases. | ||
Examples | ||
formatNum(1000) ➞ "1,000" | ||
formatNum(100000) ➞ "100,000" | ||
formatNum(20) ➞ "20" | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
Create a function that determines whether a shopping order is eligible for free shipping. An order is eligible for free shipping if the total cost of items purchased exceeds $50.00. Ignore tax or additional fees when calculating the total order cost. | ||
Examples | ||
freeShipping({ "Shampoo": 5.99, "Rubber Ducks": 15.99 }) ➞ false | ||
freeShipping({ "Flatscreen TV": 399.99 }) ➞ true | ||
freeShipping({ "Monopoly": 11.99, "Secret Hitler": 35.99, "Bananagrams": 13.99 }) ➞ true | ||
*/ |
Oops, something went wrong.