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
/* | |
You are standing at a magical well. It has two positive integers written on it: a and b. Each time you cast a magic marble into the well, it gives you a * b dollars and then both a and b increase by 1. You have n magic marbles. How much money will you make? | |
Example | |
For a = 1, b = 2, and n = 2, the output should be | |
magicalWell(a, b, n) = 8. | |
You will cast your first marble and get $2, after which the numbers will become 2 and 3. When you cast your second marble, the well will give you $6. Overall, you'll make $8. So, the output is 8. |
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
/* | |
Check if the given string is a correct time representation of the 24-hour clock. | |
Example | |
For time = "13:58", the output should be | |
validTime(time) = true; | |
For time = "25:51", the output should be | |
validTime(time) = 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
/* | |
Given a rectangular matrix and an integer column, return an array containing the elements of the columnth column of the given matrix (the leftmost column is the 0th one). | |
Example | |
For | |
matrix = [[1, 1, 1, 2], | |
[0, 5, 0, 4], | |
[2, 1, 3, 6]] |
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
/* | |
You have two integer arrays, a and b, and an integer target value v. Determine whether there is a pair of numbers, where one number is taken from a and the other from b, that can be added together to get a sum of v. Return true if such a pair exists, otherwise return false. | |
Example | |
For a = [1, 2, 3], b = [10, 20, 30, 40], and v = 42, the output should be | |
sumOfTwo(a, b, v) = true. | |
*/ | |
function sumOfTwo(a, b, v) { |
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
/* | |
Given a character, check if it represents an odd digit, an even digit or not a digit at all. | |
Example | |
For symbol = '5', the output should be | |
characterParity(symbol) = "odd"; | |
For symbol = '8', the output should be | |
characterParity(symbol) = "even"; | |
For symbol = 'q', the output should be |
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
/* | |
Check whether the given string is a subsequence of the plaintext alphabet. | |
Example | |
For s = "effg", the output should be | |
alphabetSubsequence(s) = false; | |
For s = "cdce", the output should be | |
alphabetSubsequence(s) = false; | |
For s = "ace", the output should be |
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
/* | |
Given an array of strings, return another array containing all of its longest strings. | |
Example | |
For inputArray = ["aba", "aa", "ad", "vcd", "aba"], the output should be | |
allLongestStrings(inputArray) = ["aba", "vcd", "aba"]. | |
*/ | |
function allLongestStrings(inputArray) { |
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
/* | |
A boy is walking a long way from school to his home. To make the walk more fun he decides to add up all the numbers of the houses that he passes by during his walk. Unfortunately, not all of the houses have numbers written on them, and on top of that the boy is regularly taking turns to change streets, so the numbers don't appear to him in any particular order. | |
At some point during the walk the boy encounters a house with number 0 written on it, which surprises him so much that he stops adding numbers to his total right after seeing that house. | |
For the given sequence of houses determine the sum that the boy will get. It is guaranteed that there will always be at least one 0 house on the path. | |
Example | |
For inputArray = [5, 1, 2, 3, 0, 1, 5, 0, 2], the output should be |
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
/* | |
An email address such as "John.Smith@example.com" is made up of a local part ("John.Smith"), an "@" symbol, then a domain part ("example.com"). | |
The domain name part of an email address may only consist of letters, digits, hyphens and dots. The local part, however, also allows a lot of different special characters. Here you can look at several examples of correct and incorrect email addresses. | |
Given a valid email address, find its domain part. | |
Example | |
For address = "prettyandsimple@example.com", the output should be |
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
/* | |
Proper nouns always begin with a capital letter, followed by small letters. | |
Correct a given proper noun so that it fits this statement. | |
Example | |
For noun = "pARiS", the output should be | |
properNounCorrection(noun) = "Paris"; | |
For noun = "John", the output should be |
NewerOlder