MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / largest_triangle_area

Function largest_triangle_area

812-largest-triangle-area.rs:1–12  ·  view source on GitHub ↗
(points: Vec<Vec<i32>>)

Source from the content-addressed store, hash-verified

1pub fn largest_triangle_area(points: Vec<Vec<i32>>) -> f64 {
2 let mut areas = vec!();
3 for x in points.clone() {
4 for y in points.clone() {
5 for z in points.clone() {
6 let area = 0.5 * ((x[0]*y[1] + y[0]*z[1] + z[0]*x[1] - x[0]*z[1] - y[0]*x[1] - z[0]*y[1]) as f64);
7 areas.push(area);
8 }
9 }
10 }
11 areas.into_iter().max_by(|a, b| a.partial_cmp(b).unwrap()).unwrap()
12}
13
14fn main() {
15 let points = vec![vec![0,0],vec![0,1],vec![1,0],vec![0,2],vec![2,0]];

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected