classSolution{publicintlargestRectangleArea(int[] heights){int len = heights.length;int[] newH =newint[len+2];int index =1;for(int i =0; i < len;i++){newH[index++]= heights[i];}heights = newH;len = heights.length;Stack<Integer> st =newStack<>();int res =0;st.push(0);// 单调栈for(int i =0; i < len;i++){if(heights[i]>= heights[st.peek()]){st.push(i);}else{while(heights[i]< heights[st.peek()]){int mid = st.peek();st.pop();int left = st.peek();int right = i;int h = heights[mid];int width = right-left-1;res =Math.max(res,h*width);}st.push(i);}}return res;}}
3- ACM 实现
publicclass maxArea {publicstaticintmaxA(int[] heights){int len = heights.length;int[] newH =newint[len+2];int index =1;for(int i =1; i < len;i++){newH[index++]= heights[i];}heights = newH;len = heights.length;Stack<Integer> st =newStack<>();int res =0;st.push(0);// 单调栈for(int i =0; i < len;i++){if(heights[i]>= heights[st.peek()]){st.push(i);}else{while(heights[i]< heights[st.peek()]){int mid = st.peek();st.pop();int left = st.peek();int right = i;int h = heights[mid];int width = right-left-1;res =Math.max(res,h*width);}st.push(i);}}return res;}publicstaticvoidmain(String[] args){Scanner sc =newScanner(System.in);String input = sc.nextLine();input = input.replace("[","").replace("]","");String[] parts = input.split(",");int[] nums =newint[parts.length];for(int i =0; i < nums.length;i++){nums[i]=Integer.parseInt(parts[i]);}System.out.println("结果是"+maxA(nums));}}
文章目录 问题描述 我们的Chrome浏览器在更新之后,会出现登录谷歌账号的时候,当你输入你的谷歌邮箱之后,点击 n e x t next next,也就是下一步的时候,页面没有反应,也就是没有跳转到输入密码的页面。
分析
根据logs里…