Substring with Concatenation of All Words

Description LeetCode 30 You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters. Example 1: Input: s = “barfoothefoobarman”, words = [“foo”,”bar”] Output: [0,9] Explanation: Substrings starting at

The solution of invisiable component in the layout design window

The problem is, when we want to drag a component to the layout design window, the component is not shown. But we could see the attributes of it on the right. Now find app\res\values\styles.xml and modify it. Change this line to Reference [1] https://blog.csdn.net/dafei93/article/details/80471615

Android Studio Installation for Windows 10( 64bit )

The version of Android Studio I installed is 3.1.4. Download and install Android Studio from https://developer.android.com/studio/. The position of installation is free. If after installation a dialog appears which shows “unable to access Android sdk add-on list”, then try to click cancel or modify the file Android\Android Studio\bin\idea.properties. Add the following line to the last of the

Merge k Sorted Lists

Description LeetCode 23 Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example: Input: [   1->4->5,   1->3->4,   2->6 ] Output: 1->1->2->3->4->4->5->6 Analysis Based on the idea of MergeSort, it is easy to come up with the method of selecting the minimum element each time. And extend

The reason of using “(high-low)/2+low” instead of “(low+high)/2”

When we want to calculate the middle element of a segment of array, we should use \((high-low)/2+low\) instead of \((low+high)/2\). Why? The reason is we may not know the scope of input size of the array. If it is near from the upper bound of the data type used, \(low+high\) may overflow. But \(high-low\) can’t.

Two Pointer Technique

When we need to find a pair of elements that satisfies some conditions, two pointer technique could effectively decrease the time. Generally, there are two types of two pointer. The first one is the two pointers start from the first element and the last element respectively and move to the center. The other one is

Regular Expression Matching

Description LeetCode 10 Given an input string (s) and a pattern (p), implement regular expression matching with support for ‘.’ and ‘*’. ‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). Note: s could be empty and contains only lowercase letters a-z. p could be empty and contains

Median of Two Sorted Arrays

Description LeetCode 4 There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and nums2 cannot be both empty.   Example 1: nums1 = [1, 3] nums2 = [2] The median is 2.0 Example 2: nums1 = [1,

Bit Manipulation

Bit Manipulation is a topic that is not easy to come up with without specific memory. So I conclude the useful conclusions and some typical problems here. Conclusions $$a\oplus 0=a$$ $$a\oplus a=0$$ $$a\oplus b\oplus a=(a\oplus a)\oplus b=0\oplus b=b$$ Problems 1. LeetCode 371 Description Calculate the sum of two integers a and b, but you are not allowed to use the

Maximum Subarray

Description LeetCode 53 Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. Follow up: If you have figured out the O(n) solution, try coding another solution using the divide and conquer