DP可以说是面试中比较难得题型,代码本身不会太复杂,难在想清楚问题,如何转换状态。 本文抛砖引玉,一起研究下DP专题常考的题目。
House Robber You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.
Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police....
Codelab of building web applications in Golang
This post is to introduce a type in GoLang called WaitGroup
Introduction https://golang.org/pkg/sync/#WaitGroup
A WaitGroup waits for a collection of goroutines to finish. The main goroutine calls Add to set the number of goroutines to wait for. Then each of the goroutines runs and calls Done when finished. At the same time, Wait can be used to block until all goroutines have finished.
A WaitGroup must not be copied after first use....
Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string’s permutations is the substring of the second string.
Example 1:
Input: s1 = “ab” s2 = “eidbaooo” Output: True Explanation: s2 contains one permutation of s1 (“ba”). Example 2:
Input:s1= “ab” s2 = “eidboaoo” Output: False
class Solution { public boolean checkInclusion(String s1, String s2) { Map<Character, Integer> map = new HashMap<>(); for (char ch : s1....