일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 |
31 |
- react
- codewar
- java api
- DB2
- react hook
- custom hook
- IBM
- useEffect
- TypeScript
- TABLESPACE
- descendingOrder
- type
- isSquare
- codewars
- JDBC
- Debug
- manifest.json
- Today
- Total
목록functions and trick/typescript_javascript (31)
taesik
Define a function that takes one integer argument and returns logical value true or false depending on if the integer is a prime. function isPrime(num) { if (num < 2) return false; const limit = Math.sqrt(num); for (let i = 2; i
Write a function called maxSubarraySum which accepts an array of integers and a number called n. The function should calculate the maximum sum of n consecutive elements in the array. function maxSubarraySum(arr,num) { let maxSum = 0; let tempSum = 0; if(arr.length < num) return null; for(let i =0; i< num; i++) { maxSum += arr[i]; } tempSum = maxSum; for(let i=num; i
Implement a function called countUniqueValues which accepts a sorted array, and counts the unique values in the array . There can be negative numbers in the array, but it will always be sorted. function countUniqueValues(arr) { if(arr.length ===0) return 0; let i =0; for(let j=1; j
The function should find the first pair where the sum is 0. Return an array that includes both values that sum to zero or undefined if a pair does not exist function sumZero(arr) { let left = 0; let right = arr.length -1; while(left 0) right--; else left++; }
An anagram is a word, phrase, or name formed by rearranging the letters of another. function validAnagram(first,second){ // add whatever parameters you deem necessary - good luck! if(first.length !== second.length) return false; let lookup = {}; for (let val of first.split('')) { lookup[val]? lookup[val] += 1 : lookup[val] = 1; } for(let val of second.split('')) { //can't find letter or letter i..
The frequency of values must be same. function same(arr1, arr2){ if(arr1.length !== arr2.length){ return false; } let frequencyCounter1 = {} let frequencyCounter2 = {} for(let val of arr1){ frequencyCounter1[val] = (frequencyCounter1[val] || 0) + 1 } for(let val of arr2){ frequencyCounter2[val] = (frequencyCounter2[val] || 0) + 1 } console.log(frequencyCounter1); console.log(frequencyCounter2); ..
Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits. export function duplicateCount(text: string): number{ let array = text.toLowerCase().split(''); return [...new Set(array.filter(..
Assume "#" is like a backspace in string. This means that string "a#bc#d" actually is "bd" Your task is to process a string with "#" symbols. export function cleanString(s: string) { return Array.from(s).reduce((a, b) => b == '#'? a.slice(0,-1) : a.concat(b), '') }