[LeetCode] Determine If Two Rectangles Overlap
2015-01-19 09:21
1526 查看
Question:
Given two axis-aligned rectangles A and B. Write a function to determine if the two rectangles overlap.
http://leetcode.com/2011/05/determine-if-two-rectangles-overlap.html
Given two axis-aligned rectangles A and B. Write a function to determine if the two rectangles overlap.
http://leetcode.com/2011/05/determine-if-two-rectangles-overlap.html
private static class Rectangle { public Point getLeftUp() {...} public Point getRightDown() {...} } public void overlap(Rectangle a, Rectangle b) { Point p1 = a.getLeftUp(); Point p2 = a.getRightDown(); Point p3 = b.getLeftUp(); Point p4 = b.getRightDown(); boolean notouch = p2.x < p3.x || p4.x < p1.x || p2.y < p3.y || p4.y < p1.y; return !notouch; }
相关文章推荐
- [LeetCode] Determine if two rectangles overlap
- Determine If Two Rectangles Overlap
- Best way to determine if two path reference to sam
- Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe
- Leetcode:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
- Given two strings s and t, write a function to determine if t is an anagram of s.
- LeetCode141:Given a linked list, determine if it has a cycle in it.
- Given an integer, write a function to determine if it is a power of two
- Given two strings s and t, write a function to determine if t is an anagram of s.
- determine if it is a power of two.
- [LeetCode] Merge Two Sorted Lists 混合插入有序链表
- LeetCode 160. Intersection of Two Linked Lists
- leetcode Two Sum(Java)
- [LeetCode]29. Divide Two Integers
- leetcode_add two number
- [leetcode] Merge Two Sorted Lists
- Divide Two Integers - Leetcode
- Leetcode 2. Add Two Numbers
- 【LeetCode解答二】Add Two Numbers问题Java解答
- (leetcode) Two Sum