# [LeetCode]#182. Duplicate Emails

Environment: Mysql

Key technique: N/A

Write a SQL query to find all duplicate emails in a table named `Person`.

For example, your query should return the following for the above table:

Note: All emails are in lowercase.

Solution:

Submissions:

# [LeetCode]#349. Intersection of Two Arrays

Environment: Python 3.8

Key technique: &, set , list

Given two integer arrays `nums1` and `nums2`, return an array of their intersection. Each element in the result must be unique and you may return the result in any order.

Example 1:

Analysis:

1. Use & and set to get Intersection.
2. Convert it to a list.

Solution:

Submissions:

# [LeetCode]#637. Average of Levels in Binary Tree

Environment: Python 3.8

Key technique: binarytree, Node, collections, deque

Given the `root` of a binary tree, return the average value of the nodes on each level in the form of an array. Answers within `10-5` of the actual answer will be accepted.

Example 1:

# [LeetCode]#1941. Check if All Characters Have Equal Number of Occurrences

Environment: Python 3.8

Key technique: set, Counters

Given a string `s`, return `true` if `s` is a good string, or `false` otherwise.

A string `s` is good if all the characters that appear in `s` have the same number of occurrences (i.e., the same frequency).

Example 1:

Analysis:

1. Counter it as {‘a’:2, ‘b’:2, ‘c’:2}
2. Check value is equal or not.

Solution:

Submissions:

Environment: Python 3.8

Key technique: List node

Given the `head` of a singly linked list, reverse the list, and return the reversed list.

Example 1:

Analysis:

1. Use below four steps to revise link.
4. temp.next=ans
5. ans=temp

# [LeetCode]#94. Binary Tree Inorder Traversal

Environment: Python 3.8

Key technique: binarytree, Node

Given the `root` of a binary tree, return the inorder traversal of its nodes' values.

Example 1:

Analysis:

1. Please see leetcode solution, it is very clear.

Solution:

Submissions:

# [LeetCode]#1876. Substrings of Size Three with Distinct Characters

Environment: Python 3.8

Key technique: for, if, !=

A string is good if there are no repeated characters.

Given a string `s`​​​​​, return the number of good substrings of length three in `s`​​​​​​.

Note that if there are multiple occurrences of the same substring, every occurrence should be counted.

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

Example 1:

Analysis:

1. if s[i] != s[i+1] and s[i] != s[i+2] and s[i+1] !=s[i+2], ans+=1.
2. Return ans

Solution:

Submissions:

# [LeetCode]#338. Counting Bits

Environment: Python 3.8

Key technique: bin, append, replace

Given an integer `n`, return an array `ans` of length `n + 1` such that for each `i` (`0 <= i <= n`), `ans[i]` is the number of `1`'s in the binary representation of `i`.

Example 1:

Analysis:

1. Use loop and n is loop end. Convert input number to binary such as 1 to ‘0b1’.
2. Replace ‘ob’ with ‘’.
3. Count all ‘1’ numbers.
4. Add them to the list.

Solution:

Submissions:

Reference:

https://leetcode.com/problems/counting-bits/discuss/1348058/python

# [LeetCode]#1880. Check if Word Equals Summation of Two Words

Environment: Python 3.8

Key technique: ASCII

The letter value of a letter is its position in the alphabet starting from 0 (i.e. `'a' -> 0`, `'b' -> 1`, `'c' -> 2`, etc.).

The numerical value of some string of lowercase English letters `s` is the concatenation of the letter values

# [LeetCode]#1837. Sum of Digits in Base K

Environment: Python 3.8

Key technique: //, %

Given an integer `n` (in base `10`) and a base `k`, return the sum of the digits of `n` after converting `n` from base `10` to base `k`.

After converting, each digit should be interpreted as a base `10` number, and the sum should be returned in base `10`.

Example 1:

Analysis:

1. Calculate quotient and remainder between n and k.
2. If update n > k, continue step1.
3. If update n≤k, stop calculate.
4. Summarize the current quotient and remainder.

Solution:

Submissions: ## Fatboy Slim

Interesting in any computer science.