add previous solutions
parent
c702e07dd9
commit
e296a1bcc3
|
@ -0,0 +1 @@
|
|||
package anagrams
|
|
@ -0,0 +1,22 @@
|
|||
What is an anagram? Well, two words are anagrams of each other if they both contain the same letters. For example:
|
||||
|
||||
```js
|
||||
'abba' & 'baab' == true
|
||||
|
||||
'abba' & 'bbaa' == true
|
||||
|
||||
'abba' & 'abbba' == false
|
||||
|
||||
'abba' & 'abca' == false
|
||||
```
|
||||
|
||||
Write a function that will find all the anagrams of a word from a list. You will be given two inputs a word and an array with words. You should return an array of all the anagrams or an empty array if there are none. For example:
|
||||
|
||||
```js
|
||||
anagrams('abba', ['aabb', 'abcd', 'bbaa', 'dada']) => ['aabb', 'bbaa']
|
||||
|
||||
anagrams('racer', ['crazer', 'carer', 'racar', 'caers', 'racer']) => ['carer', 'racer']
|
||||
|
||||
anagrams('laser', ['lazing', 'lazy', 'lacer']) => []
|
||||
```
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package camelcase
|
||||
|
||||
func Camelcase(s string) string {
|
||||
return s
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
Write simple .camelCase method (camel_case function in PHP, CamelCase in C# or camelCase in Java) for strings. All words must have their first letter capitalized without spaces.
|
||||
|
||||
For instance:
|
||||
|
||||
```js
|
||||
"hello case".camelCase() // => HelloCase
|
||||
"camel case word".camelCase() // => CamelCaseWord
|
||||
```
|
||||
|
|
@ -0,0 +1 @@
|
|||
package pangram
|
|
@ -0,0 +1,4 @@
|
|||
A pangram is a sentence that contains every single letter of the alphabet at least once. For example, the sentence "The quick brown fox jumps over the lazy dog" is a pangram, because it uses the letters A-Z at least once (case is irrelevant).
|
||||
|
||||
Given a string, detect whether or not it is a pangram. Return True if it is, False if not. Ignore numbers and punctuation.
|
||||
|
|
@ -0,0 +1 @@
|
|||
package prime
|
|
@ -0,0 +1,17 @@
|
|||
Define a function that takes an integer argument and returns logical value `true` or `false` depending on if the integer is a prime.
|
||||
|
||||
Per Wikipedia, a prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.
|
||||
Example
|
||||
|
||||
```js
|
||||
is_prime(1) /* false */
|
||||
is_prime(2) /* true */
|
||||
is_prime(-1) /* false */
|
||||
```
|
||||
|
||||
Assumptions
|
||||
|
||||
- You can assume you will be given an integer input.
|
||||
- You can not assume that the integer will be only positive. You may be given negative numbers as well (or `0`).
|
||||
- There are no fancy optimizations required, but still the most trivial solutions might time out. Try to find a solution which does not loop all the way up to `n`.
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
*How to shuffle the characters in a string in JavaScript ?*
|
||||
|
||||
e.g. Given "ABCDEFG", return something like "GEFBDCA".
|
||||
|
||||
```js
|
||||
print(shuffle("the quick brown fox jumps over the lazy dog"));
|
||||
//-> "veolrm hth ke opynug tusbxq ocrad ofeizwj"
|
||||
|
||||
print(shuffle("the quick brown fox jumps over the lazy dog"));
|
||||
//-> "o dt hutpe u iqrxj yaenbwoolhsvmkcger ozf "
|
||||
```
|
||||
|
||||
- Best performance case: O(n)
|
||||
- Worst performance case: O(n log n)
|
||||
|
Loading…
Reference in New Issue