1. LeetCode 3 题 demand: https://leetcode-cn.com/probl…

Given a string s, find the longest string that does not contain repeating characters. Input: s = “pwwkew” Output: 3 Explanation: Since the oldest string with no duplicate characters is “wke”, its length is 3. Note that your answer must be the length of the substring, “pwke” is a subsequence, not a substring.

function print(s) { let str = ""; let size = 0; for (let i = 0; i < s.length; I ++) {if (str.includes(s[I])) {STR = str.substr(I + 1); } else { str += s[i]; Size = size < str.length? str.length : size; } } return size; }

2. LeetCode 4 题 demand: https://leetcode-cn.com/probl…

Given two positively ordered (small to large) arrays nums1 and nums2 of size m and n, respectively. Find and return the median of the two positive sequences.

Example 1: Input: nums1 = [1,3], nums2 = [2] Output: 2 Explanation: Merge array = [1,2,3], median 2
Input: nums1 = [1,2], nums2 = [3,4] output: 2.5 explanation: merge array = [1,2,3,4], median (2 + 3) / 2 = 2.5
Example 3: Input: nums1 = [0,0], nums2 = [0,0] Output: 0
Example 4: Input: nums1 = [], nums2 = [1] Output: 1
Example 5: Input: nums1 = [2], nums2 = [] Output: 2
function print(nums1, nums2) { let m = nums1.length - 1; let n = nums2.length - 1; let k = end = m + n + 1; while (m >= 0 && n >= 0) { if (nums1[m] <= nums2[n]) { nums1[k] = nums2[n]; n--; k--; } else { nums1[k] = nums1[m]; m--; k--; } } while (n >= 0) { nums1[k] = nums2[n]; k--; n--; } let middleStr = (end / 2).tostring ();} let middleStr = (end / 2).tostring (); let middleIndex = Math.floor(end/ 2); If (middleStr. Includes (".")) {// (2 + 3) /2=2.5 return (nums1[middleIndex] + nums1[middleIndex + 1]) / 2; } else {//[1,2,3] middleStr = 2 print 2 return nums1[middleStr] / 1; }}