This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| You will be supplied with two data files in CSV format . | |
| The first file contains statistics about various dinosaurs. The second file contains additional data. | |
| Given the following formula, `speed = ((STRIDE_LENGTH / LEG_LENGTH) - 1) * SQRT(LEG_LENGTH * g)` | |
| Where g = 9.8 m/s^2 (gravitational constant) | |
| Write a program to read in the data files from disk, it must then print the names of only the bipedal dinosaurs from fastest to slowest. | |
| Do not print any other information. | |
| $ cat dataset1.csv | |
| NAME,LEG_LENGTH,DIET |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Solution { | |
| public int largestRectangleArea(int[] heights) { | |
| if (heights == null || heights.length < 1) return 0; | |
| int res = 0; | |
| int len = heights.length; | |
| Stack<Integer> stack = new Stack<>(); | |
| stack.push(-1); | |
| for (int i = 0; i < len; i++) { | |
| while (stack.peek() != -1 && heights[i] <= heights[stack.peek()]) { | |
| res = Math.max(res, heights[stack.pop()] * (i - stack.peek() - 1)); |