feat(interview-prep): Updated descriptions and corrected syntax
This commit is contained in:
committed by
Kristofer Koishigawa
parent
e4a6f5563f
commit
ec0a5e0b6f
@ -19,7 +19,7 @@ Child 2: snake
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
Write a function that takes an input array of words. The function should return an array of words where the first letter of each word is the same as the last letter of the previous word. The first word in the return array can be anything. Use only the words in the input array, and once a word is used it cannot be repeated. The words in the return array should be selected and sequenced so that that the length of the array is maximized.
|
||||
Write a function that takes an input array of words. The function should return an array of words where the first letter of each word is the same as the last letter of the previous word. Only use the words in the input array, and once a word is used it cannot be repeated. The words in the return array should be selected and sequenced so that that its length is maximized.
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
@ -51,7 +51,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function findLongestChain (items) {
|
||||
function findLongestChain(items) {
|
||||
// Good luck!
|
||||
}
|
||||
```
|
||||
@ -64,7 +64,7 @@ function findLongestChain (items) {
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
function findLongestChain (items) {
|
||||
function findLongestChain(items) {
|
||||
function Ref(index, first_char, last_char) {
|
||||
this.index = index;
|
||||
this.first_char = first_char;
|
||||
|
@ -6,7 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
You are given a string and your task is to calculate frequency of each character.
|
||||
Given a string, calculate the frequency of each character.
|
||||
All characters should be counted. This includes lower and upper case letters, digits, whitespace, special characters, or any other distinct characters.
|
||||
</section>
|
||||
|
||||
@ -48,7 +48,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function letterFrequency (txt) {
|
||||
function letterFrequency(txt) {
|
||||
// Good luck!
|
||||
}
|
||||
```
|
||||
@ -61,7 +61,7 @@ function letterFrequency (txt) {
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
function letterFrequency (txt) {
|
||||
function letterFrequency(txt) {
|
||||
var cs = txt.split(''),
|
||||
i = cs.length,
|
||||
dct = {},
|
||||
|
@ -6,19 +6,21 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
In information theory and computer science, the <b>Levenshtein distance</b> is a <a href="https://en.wikipedia.org/wiki/string metric">metric</a> for measuring the amount of difference between two sequences (i.e. an <a href="https://en.wikipedia.org/wiki/edit distance">edit distance</a>). The Levenshtein distance between two strings is defined as the minimum number of edits needed to transform one string into the other, with the allowable edit operations being insertion, deletion, or substitution of a single character.
|
||||
In information theory and computer science, the <strong>Levenshtein distance</strong> is a <a href="https://en.wikipedia.org/wiki/string metric">metric</a> for measuring the amount of difference between two sequences (i.e. an <a href="https://en.wikipedia.org/wiki/edit distance">edit distance</a>). The Levenshtein distance between two strings is defined as the minimum number of edits needed to transform one string into the other, with the allowable edit operations being insertion, deletion, or substitution of a single character.
|
||||
Example:
|
||||
The Levenshtein distance between "<b>kitten</b>" and "<b>sitting</b>" is 3, since the following three edits change one into the other, and there isn't a way to do it with fewer than three edits:
|
||||
<b>k</b>itten <b>s</b>itten (substitution of 'k' with 's')</b>
|
||||
sitt<b>e</b>n sitt<b>i</b>n (substitution of 'e' with 'i')</b>
|
||||
sittin sittin<b>g</b> (insert 'g' at the end).</b>
|
||||
''The Levenshtein distance between "<b>rosettacode</b>", "<b>raisethysword</b>" is <b>8</b>.
|
||||
The Levenshtein distance between "<strong>kitten</strong>" and "<strong>sitting</strong>" is 3, since the following three edits change one into the other, and there isn't a way to do it with fewer than three edits:
|
||||
<ul>
|
||||
<li><strong>k</strong>itten <strong>s</strong>itten (substitution of 'k' with 's')</strong></li>
|
||||
<li>sitt<strong>e</strong>n sitt<strong>i</strong>n (substitution of 'e' with 'i')</strong></li>
|
||||
<li>sittin sittin<strong>g</strong> (insert 'g' at the end).</strong></li>
|
||||
</ul>
|
||||
<i>The Levenshtein distance between "<strong>rosettacode</strong>", "<strong>raisethysword</strong>" is <strong>8</strong>.</i>
|
||||
<i>The distance between two strings is same as that when both strings are reversed.</i>
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
Write a function that returns the Levenshtein distance between two strings given as parameters .
|
||||
Write a function that returns the Levenshtein distance between two strings given as parameters.
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
@ -52,7 +54,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function levenshtein (a, b) {
|
||||
function levenshtein(a, b) {
|
||||
// Good luck!
|
||||
}
|
||||
```
|
||||
@ -65,7 +67,7 @@ function levenshtein (a, b) {
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
function levenshtein (a, b) {
|
||||
function levenshtein(a, b) {
|
||||
var t = [], u, i, j, m = a.length, n = b.length;
|
||||
if (!m) { return n; }
|
||||
if (!n) { return m; }
|
||||
|
@ -52,7 +52,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function linearCongGenerator (r0, a, c, m, n) {
|
||||
function linearCongGenerator(r0, a, c, m, n) {
|
||||
// Good luck!
|
||||
}
|
||||
```
|
||||
|
@ -8,12 +8,12 @@ challengeType: 5
|
||||
<section id='description'>
|
||||
Explicitly implement <a href="https://en.wikipedia.org/wiki/long multiplication">long multiplication</a>.
|
||||
This is one possible approach to arbitrary-precision integer algebra.
|
||||
Note: In JavaScript, arithmetic operations are inaccurate with large numbers, so you will have to implement precise multiplication yourself.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
Write a function that takes two strings of large numbers as parameters. Your function should return the product of these two large numbers as a string.
|
||||
<strong>Note:</strong> In JavaScript, arithmetic operations are inaccurate with large numbers, so you will have to implement precise multiplication yourself.
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
@ -45,7 +45,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function mult (strNum1, strNum2) {
|
||||
function mult(strNum1, strNum2) {
|
||||
// Good luck!
|
||||
}
|
||||
```
|
||||
|
Reference in New Issue
Block a user