Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- java api
- react hook
- Debug
- isSquare
- useEffect
- type
- codewar
- descendingOrder
- DB2
- JDBC
- TABLESPACE
- codewars
- IBM
- react
- manifest.json
- TypeScript
- custom hook
Archives
- Today
- Total
taesik
contain_all_rotation 본문
contain_all_rots(strng, arr) (or containAllRots or contain-all-rots):
- a boolean true if all rotations of strng are included in arr (C returns 1)
- false otherwise (C returns 0)
더보기
export function containAllRots($: string, arr: string[]): boolean {
arr = arr.map(e => e.toLowerCase());
const arr$ = Array.from({length: $.length}, x => $.toLowerCase())
.map((el, i)=> el.slice(i)+el.slice(0,i))
return arr$.every(e => arr.includes(e))
}
<rotaition>
.map((element, index)=>element.slice(index)+element.slice(0,index))
'functions and trick > typescript_javascript' 카테고리의 다른 글
| 2D array of number. to find the sum of minimum value in each row. (0) | 2022.01.24 |
|---|---|
| has the same amount of 'x's and 'o's. (0) | 2022.01.23 |
| Nth Smallest Element (0) | 2022.01.23 |
| Count the number of occurrences of each character and return it as a list of tuples in order (0) | 2022.01.23 |
| number to string[] (0) | 2022.01.23 |