 # LeetCode — Number of common factors (Weekly contest)

TBE

Solution:
Time complexity: O(N)

Space complexity: O(1)

--

--

# LeetCode — Longest Palindromic Substring (Blind Curated)

Given a string `s`, return the longest palindromic substring in `s`.

A string is called a palindrome string if the reverse of that string is the same as the original string.

Example 1:

`Input: s = "babad"Output: "bab"Explanation: "aba" is also a valid answer.`

Example 2:

`Input: s = "cbbd"Output: "bb"`

Constraints:

• `1 <= s.length <= 1000`
• `s` consist of only digits and English letters.

Solution:

Time complexity: O(N)

Space complexity: O(N)

--

--

# LeetCode — Longest Substring without reapting characters (MSFT)

Given a string `s`, find the length of the longest substring without repeating characters.

Example 1:

`Input: s = "abcabcbb"Output: 3Explanation: The answer is "abc", with the length of 3.`

Example 2:

`Input: s = "bbbbb"Output: 1Explanation: The answer is "b", with the length of 1.`

Example 3:

`Input: s = "pwwkew"Output: 3Explanation: The answer is "wke", with the length of 3.Notice that the answer must be a substring, "pwke" is a subsequence and not a substring.`

Constraints:

• `0 <= s.length <= 5 * 104`
• `s` consists of English letters, digits, symbols and spaces.

Solution:

Time complexity: O(N)

Space complexity: O(N)

--

--

# LeetCode — Find the duplicated number

Given an array of integers `nums` containing `n + 1` integers where each integer is in the range `[1, n]` inclusive.

There is only one repeated number in `nums`, return this repeated number.

You must solve the problem without modifying the array `nums` and uses only constant extra space.

Example 1:

`Input: nums = [1,3,4,2,2]Output: 2`

Example 2:

`Input: nums = [3,1,3,4,2]Output: 3`

Constraints:

• `1 <= n <= 105`
• `nums.length == n + 1`
• `1 <= nums[i] <= n`
• All the integers in `nums` appear only once except for precisely one integer which appears two or more times.

Solution:

--

--

# LeetCode — Longest Palindrome

Given a string `s` which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters.

Letters are case sensitive, for example, `"Aa"` is not considered a palindrome here.

Example 1:

`Input: s = "abccccdd"Output: 7Explanation: One longest palindrome that can…`

--

--

# LeetCode — Spiral Matrix II

Given a positive integer `n`, generate an `n x n` `matrix` filled with elements from `1` to `n2` in spiral order.

Example 1:

`Input: n = 3Output: [[1,2,3],[8,9,4],[7,6,5]]`

Example 2:

`Input: n = 1Output: []`

Constraints:

• `1 <= n <= 20`

Solution:

--

--