593. Valid Square Medium

@problem@discussion
#Math#Geometry



1/**
2 * [593] Valid Square
3 *
4 * Given the coordinates of four points in 2D space p1, p2, p3 and p4, return true if the four points construct a square.
5 * The coordinate of a point pi is represented as [xi, yi]. The input is not given in any order.
6 * A valid square has four equal sides with positive length and four equal angles (90-degree angles).
7 *  
8 * Example 1:
9 * 
10 * Input: p1 = [0,0], p2 = [1,1], p3 = [1,0], p4 = [0,1]
11 * Output: true
12 * 
13 * Example 2:
14 * 
15 * Input: p1 = [0,0], p2 = [1,1], p3 = [1,0], p4 = [0,12]
16 * Output: false
17 * 
18 * Example 3:
19 * 
20 * Input: p1 = [1,0], p2 = [-1,0], p3 = [0,1], p4 = [0,-1]
21 * Output: true
22 * 
23 *  
24 * Constraints:
25 * 
26 * 	p1.length == p2.length == p3.length == p4.length == 2
27 * 	-10^4 <= xi, yi <= 10^4
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/valid-square/
33// discuss: https://leetcode.com/problems/valid-square/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn valid_square(p1: Vec<i32>, p2: Vec<i32>, p3: Vec<i32>, p4: Vec<i32>) -> bool {
39        false
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_593() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.