# [LeetCode]#2078. Two Furthest Houses With Different Colors

Environment: Python 3.8

Key technique: enumerate, if

There are `n` houses evenly lined up on the street, and each house is beautifully painted. You are given a 0-indexed integer array `colors` of length `n`, where `colors[i]` represents the color of the `ith` house.

Return the maximum distance between two houses…

# [LeetCode]#2085. Count Common Words With One Occurrence

Environment: Python 3.8

Key technique: set, list

Given two string arrays `words1` and `words2`, return the number of strings that appear exactly once in each of the two arrays.

Example 1:

`Input: words1 = ["leetcode","is","amazing","as","is"], words2 = ["amazing","leetcode","is"]Output: 2Explanation:- "leetcode" appears exactly once in each of the two arrays. We…`

# [LeetCode]#2032. Two Out of Three

Environment: Python 3.8

Key technique: set, list

Given three integer arrays `nums1`, `nums2`, and `nums3`, return a distinct array containing all the values that are present in at least two out of the three arrays. You may return the values in any order.

Example 1:

`Input: nums1 = [1,1,3,2], nums2 = [2,3], nums3 = [3]Output: [3,2]Explanation: The values that are present in at least two arrays are:- 3, in all three arrays.- 2, in nums1 and nums2.`

Analysis:

1. get nums1, nums2, nums3 all possible set.
2. set three sets and output it.

Solution:

`class Solution:    def twoOutOfThree(self, nums1, nums2, nums3):                seta=set(nums1) & set(nums2)        setb=set(nums2) & set(nums3)        setc=set(nums1) & set(nums3)        return set(list(seta) + list(setb) + list(setc))`

Submissions:

# [LeetCode]#2089. Find Target Indices After Sorting Array

Environment: Python 3.8

Key technique: sort, for

You are given a 0-indexed integer array `nums` and a target element `target`.

A target index is an index `i` such that `nums[i] == target`.

Return a list of the target indices of `nums` after sorting `nums` in non-decreasing order. If there are no target indices, return an empty list. The returned list must be sorted in increasing order.

Example 1:

`Input: nums = [1,2,5,2,3], target = 2Output: [1,2]Explanation: After sorting, nums is [1,2,2,3,5].The indices where nums[i] == 2 are 1 and 2.`

Analysis:

1. Sort it.
2. find the target in sorted nums.
3. return its index.

Solution:

`class Solution:    def targetIndices(self, nums, target):        nums.sort()        ans=[]        for i in range(len(nums)):            if nums[i]==target:                ans.append(i)        return ans`

Submissions:

# [LeetCode]#1974. Minimum Time to Type Word Using Special Typewriter

Environment: Python 3.8

Key technique: ord, for, if

There is a special typewriter with lowercase English letters `'a'` to `'z'` arranged in a circle with a pointer. A character can only be typed if the pointer is pointing to that character. The pointer is initially pointing to the character `'a'`.

# [LeetCode]#2053. Kth Distinct String in an Array

Environment: Python 3.8

Key technique: Counter, for, if

A distinct string is a string that is present only once in an array.

Given an array of strings `arr`, and an integer `k`, return the `kth` distinct string present in `arr`. …

# [LeetCode]#2057. Smallest Index With Equal Value

Environment: Python 3.8

Key technique: for, %

Given a 0-indexed integer array `nums`, return the smallest index `i` of `nums` such that `i mod 10 == nums[i]`, or `-1` if such index does not exist.

`x mod y` denotes the remainder when `x` is divided by `y`.

Example 1:

`Input…`

# [LeetCode]#1967. Number of Strings That Appear as Substrings in Word

Environment: Python 3.8

Key technique: for, in

Given an array of strings `patterns` and a string `word`, return the number of strings in `patterns` that exist as a substring in `word`.

A substring is a contiguous sequence of characters within a string.

Example 1:

`Input: patterns = ["a","abc","bc","d"], word = "abc"Output: 3Explanation:- "a" appears as a substring in "abc".- "abc" appears as a substring in "abc".- "bc" appears as a substring in "abc".- "d" does not appear as a substring in "abc".3 of the strings in patterns appear as a substring in word.`

Analysis:

1. Check patterns is in word.
2. If yes, ans=ans+1
3. return ans

Solution:

`class Solution:    def numOfStrings(self, patterns, word):        ans=0        for i in patterns:            if i in word:                ans+=1        return ans`

Submissions:

# [Work][Python]Ping test

Environment: Python 3.8

Key technique: platform, subprocess, datetime

Task: Test wifi card connect stability

Step:

1. ping to AP/other system/ google.com.

2. Check every hour packet lost rate.

Passe criteria:

1. packet loss rate is less than 1%.

Note

• Losses between 5% and 10% of the total packet stream will…

# [LeetCode]#2000. Reverse Prefix of Word

Environment: Python 3.8

Key technique: find, string

Given a 0-indexed string `word` and a character `ch`, reverse the segment of `word` that starts at index `0` and ends at the index of the first occurrence of `ch` (inclusive). If the character `ch` does not exist in `word`, do nothing.

• For…

## Fatboy Slim

Interesting in any computer science.

Get the Medium app