Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 75aa67a

Browse files
chore(book/questions): improve function documentation
1 parent f40dc63 commit 75aa67a

12 files changed

+35
-7
lines changed

‎book/interview-questions/binary-tree-right-side-view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { Queue } = require('../../src/index');
44
/**
55
* Find the rightmost nodes by level.
66
*
7-
* @example
7+
* @example rightSideView(bt([1,2,3,4])); // [1, 3, 4]
88
* 1 <- 1
99
* / \
1010
* 2 3 <- 3

‎book/interview-questions/buy-sell-stock.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* maxProfit([1, 2, 3]); // => 2
77
* maxProfit([3, 2, 1]); // => 0
88
* @param {number[]} prices - Array with daily stock prices
9+
* @returns {number} - Max profit
910
*/
1011
function maxProfit(prices) {
1112
// end::description[]

‎book/interview-questions/daily-temperatures.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* dailyTemperatures([73, 69, 72, 76, 73]); // [3, 1, 1, 0, 0]
1010
*
1111
* @param {number[]} t - Daily temperatures
12+
* @returns {number[]} - Array with count of days to warmer temp.
1213
*/
1314
function dailyTemperatures(t) {
1415
// end::description[]

‎book/interview-questions/linkedlist-same-data.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
* hasSameData(['he', 'll', 'o'], ['hel', 'lo']); // true
1010
* hasSameData(['hel', 'lo'], ['hi']); // false
1111
*
12-
* @param {ListNode} l1 - The root node of list 1
13-
* @param {ListNode} l2 - The root node of list 2
12+
* @param {ListNode} l1 - The root node of list 1.
13+
* @param {ListNode} l2 - The root node of list 2.
14+
* @returns {boolean} - true if has same data, false otherwise.
1415
*/
1516
function hasSameData(l1, l2) {
1617
// end::description[]

‎book/interview-questions/longest-substring-without-repeating-characters.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
// tag::description[]
2+
/**
3+
* Find the length of the longest substring without duplicates.
4+
* @example lenLongestSubstring('abccxyz'); // => 4 (cxyz)
5+
* @param {string} s - The string.
6+
* @returns {number} - The length of the longest unique substring.
7+
*/
28
function lenLongestSubstring(s) {
39
// end::description[]
410
// tag::placeholder[]

‎book/interview-questions/max-subarray.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* maxSubArray([-3,4,-1,2,1,-5]); // => 6
88
*
99
* @param {number[]} a - Array
10+
* @returns {number} - max sum
1011
*/
1112
function maxSubArray(a) {
1213
// end::description[]

‎book/interview-questions/merge-lists.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const ListNode = require('../../src/data-structures/linked-lists/node');
99
*
1010
* @param {ListNode} l1 - The root node of list 1
1111
* @param {ListNode} l2 - The root node of list 2
12+
* @returns {ListNode} - The root of the merged list.
1213
*/
1314
function mergeTwoLists(l1, l2) {
1415
// end::description[]

‎book/interview-questions/most-common-word.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// tag::description[]
22
/**
33
* Find the most common word that is not banned.
4-
*
4+
*@example mostCommonWord("It's blue and it's round", ['and']) // it
55
* @param {string} paragraph - The text to sanitize and search on.
66
* @param {string[]} banned - List of banned words (lowercase)
7+
* @returns {string} - The first word that is the most repeated.
78
*/
89
function mostCommonWord(paragraph, banned) {
910
// end::description[]

‎book/interview-questions/recent-counter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const { Queue } = require('../../src/index');
55
* Counts the most recent requests within a time window.
66
* Each request has its timestamp.
77
* If the time window is 2 seconds,
8-
* any requests that happened more than 2 seconds before the most recent request
9-
* should not count.
8+
* any requests that happened more than 2 seconds before the most
9+
* recent request should not count.
1010
*
1111
* @example - The time window is 3 sec. (3000 ms)
1212
* const counter = new RecentCounter(3000);

‎book/interview-questions/subarray-sum-equals-k.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
// tag::description[]
2+
/**
3+
* Find the number of subarrays that add up to k.
4+
* @example subarraySum([1, -1, 1], 0); // 3 ([1,-1,1], [1], [1])
5+
* @param {number[]} nums - Array of integers.
6+
* @param {number} k - The target sum.
7+
* @returns {number} - The number of solutions.
8+
*/
29
function subarraySum(nums, k) {
310
// end::description[]
411
// tag::placeholder[]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /