Hhh I will change to Lintcode for a while~
Lintcode 626 Rectangle Overlay
Description:
Given two rectangles, find if the given two rectangles overlap or not.
Methods:
If we classify different situations for overlap, that would be a huge amount of work.
So we can consider when these two squares are not overlapped.
Code:
|
|
Lintcode 628 Maximum Subtree
Description:
Given a binary tree, find the subtree with maximum sum. Return the root of the subtree.
Methods:
Divide the work into two parts:
- to calculate the sum of each node and its childnodes;
- to update maxinum and the TreeNode.
So we need to use global variables.
Code:
|
|
Lintcode 627 Longest Palindrome
Description:
Given a string whichconsists of lowercase or uppercase letters, find the length of the longestpalindromes that can be built with those letters.
This is case sensitive, forexample “Aa” is not considered apalindrome here.
Methods:
Not very hard. Use hash and to count even and odd number.
But the most important is that ! Get even by substract one from odd!!
Code:
|
|