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
function isPalindrone(word) { | |
let lettersCounter = 1; | |
for(let i = 0; i < word.length; i++) { | |
if(word[i] == word[word.length - lettersCounter]) { | |
lettersCounter++; | |
if (lettersCounter == word.length) { | |
return 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
function isPalindrone(word) { | |
// This approach converts the string into an array and then reverses it | |
// Split splits the string into an array, each letter of the word is it's own array element | |
// Reverse reverses the array elements but they are still separate characters spaced out | |
// Join squishes the letters back into be one solid word without spaces between characters | |
let reversed = word.split('').reverse().join(''); | |
// Compare orginal word to reversed word | |
if( word == reversed) { |
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
import React, { Component } from "react"; | |
import styled, { css } from "styled-components"; | |
const Styles = styled.div` | |
.red { | |
background: red; | |
height: 5em; | |
width: 5em; | |
display: inline-block; | |
margin: 1em; |
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
/* | |
CodeSignal adjacentElementsProduct problem: | |
Given an array of integers, find the pair of adjacent elements that has the largest product and return that product. | |
Example | |
For inputArray = [3, 6, -2, -5, 7, 3], the output should be | |
adjacentElementsProduct(inputArray) = 21. |
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
/* | |
CodeSignal Add Two Digits Problem: | |
You are given a two-digit integer n. Return the sum of its digits. | |
Example | |
For n = 29, the output should be | |
addTwoDigits(n) = 11. |
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
/* | |
CodeSignal: Given an integer n, return the largest number that contains exactly n digits. | |
Example | |
For n = 2, the output should be | |
largestNumber(n) = 99. | |
Input/Output |
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
/* | |
CodeSignal Candies: | |
n children have got m pieces of candy. They want to eat as much candy as they can, but each child must eat exactly the same amount of candy as any other child. Determine how many pieces of candy will be eaten by all the children together. Individual pieces of candy cannot be split. | |
Example | |
For n = 3 and m = 10, the output should be | |
candies(n, m) = 9. |
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
/* | |
Your friend advised you to see a new performance in the most popular theater in the city. He knows a lot about art and his advice is usually good, but not this time: the performance turned out to be awfully dull. It's so bad you want to sneak out, which is quite simple, especially since the exit is located right behind your row to the left. All you need to do is climb over your seat and make your way to the exit. | |
The main problem is your shyness: you're afraid that you'll end up blocking the view (even if only for a couple of seconds) of all the people who sit behind you and in your column or the columns to your left. To gain some courage, you decide to calculate the number of such people and see if you can possibly make it to the exit without disturbing too many people. | |
Given the total number of rows and columns in the theater (nRows and nCols, respectively), and the row and column you're sitting in, return the number of people who sit strictly behind you and in your column or to the left, assuming all |
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 divisor and a bound, find the largest integer N such that: | |
N is divisible by divisor. | |
N is less than or equal to bound. | |
N is greater than 0. | |
It is guaranteed that such a number exists. | |
Example |
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"]. | |
*/ |