1.5k words 1 mins.

# DOM # 簡介 DOM (document object model,文件物件模型) 由 W3C (world wide web consortium) 定義,DOM 將 HTML 內的所有 element 定義成物件,並以樹狀結構表示。 DOM 樹狀結構 source # 結構 DOM 的節點大致分為四類: Document: HTML 文件本身,也就是 root node。 Element: 文件裡的標籤,如 <head> 、 <body> 、 <div> 等。 Text: 被 element...
961 words 1 mins.

⭐️ # 題目敘述 Given an integer array arr and a mapping function fn , return a new array with a transformation applied to each element. The returned array should be created such that returnedArray[i] = fn(arr[i], i) . Please solve it without the built-in Array.map method. # Example 1 Input: arr =...
871 words 1 mins.

⭐️ # 題目敘述 Given a square matrix mat , return the sum of the matrix diagonals. Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal. # Example 1 Input: mat = [[1,2,3], [4,5,6], [7,8,9]] Output:...
1.5k words 1 mins.

⭐️ # 題目敘述 Write a function createCounter . It should accept an initial integer init . It should return an object with three functions. The three functions are: increment() increases the current value by 1 and then returns it. decrement() reduces the current value by 1 and then returns it. reset()...
1.2k words 1 mins.

⭐️⭐️ # 題目敘述 You are given an array of integers nums and an integer target . Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target . Since the answer may be too large, return it modulo 10^9 + 7 . # Example 1 Input:...
998 words 1 mins.

⭐️ # 題目敘述 Given an integer n , return a counter function. This counter function initially returns n and then returns 1 more than the previous value every subsequent time it is called ( n , n + 1 , n + 2 , etc). # Example 1 Input: n = 10 [“call”,“call”,“call”] Output:...
805 words 1 mins.

⭐️ # 題目敘述 Write a function createHelloWorld . It should return a new function that always returns "Hello World" . # Example 1 Input: args = [] Output: “Hello World” Explanation: const f = createHelloWorld(); f(); // “Hello World” The function returned by createHelloWorld should...
1.1k words 1 mins.

⭐️⭐️ # 題目敘述 Given a string s and an integer k , return the maximum number of vowel letters in any substring of s with length k . Vowel letters in English are 'a' , 'e' , 'i' , 'o' , and 'u' . # Example 1 Input: s = “abciiidef”, k = 3 Output: 3 Explanation:...
2.3k words 2 mins.

⭐️⭐️⭐️ # 題目敘述 You want to build some obstacle courses. You are given a 0-indexed integer array obstacles of length n , where obstacles[i] describes the height of the ith obstacle. For every index i between 0 and n - 1 (inclusive), find the length of the longest obstacle course in obstacles such...
2.9k words 3 mins.

⭐️⭐️ # 題目敘述 In the world of Dota2, there are two parties: the Radiant and the Dire. The Dota2 senate consists of senators coming from two parties. Now the Senate wants to decide on a change in the Dota2 game. The voting for this change is a round-based procedure. In each round, each senator can...