上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 39 下一页
摘要: 均分最大深度 遍历seq计算最大深度maxDepth遍历seq,遇到"(",当A子序列的最大深度小于ceil(maxDepth/2)时分配给A,反之分配给B遇到")", 当A的最大深度不为0时说明A子序列还有未被匹配的"(",所以分配给A,否则分配给B class Solution { public 阅读全文
posted @ 2020-10-07 15:27 消灭猕猴桃 阅读(76) 评论(0) 推荐(0) 编辑
摘要: 回溯法 每使用一个字符就往栈中添加一个字符,如果该字符已经使用过则跳过该字符。回溯时从栈中删除字符。 class Solution { public String[] permutation(String S) { if (S.length() == 0) return new String[]{} 阅读全文
posted @ 2020-10-07 10:41 消灭猕猴桃 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 回溯 class Solution { private List<List<Integer>> ans = new LinkedList<>(); public List<List<Integer>> permute(int[] nums) { backTrace(nums, 0); return 阅读全文
posted @ 2020-10-06 12:25 消灭猕猴桃 阅读(56) 评论(0) 推荐(0) 编辑
摘要: 回溯法 class Solution { // 一共9行,一行9个数字 private boolean[][] line = new boolean[9][9]; // 一共9列,一列9个数字 private boolean[][] column = new boolean[9][9]; // 一共 阅读全文
posted @ 2020-10-06 10:56 消灭猕猴桃 阅读(105) 评论(0) 推荐(0) 编辑
摘要: class Solution { public List<String> generateParenthesis(int n) { List<String> ans = new LinkedList<>(); backtrack(ans, n, 0, ""); return ans; } // 回溯 阅读全文
posted @ 2020-10-06 09:31 消灭猕猴桃 阅读(66) 评论(0) 推荐(0) 编辑
摘要: 前言 在深度学习中,图像的数据类型为torch,其形状(shape)为:(C, H, W)。在opencv中图像的数据类型为nda... 阅读全文
posted @ 2020-10-05 21:49 消灭猕猴桃 阅读(2602) 评论(0) 推荐(0) 编辑
摘要: 回溯法 class Solution { static final int SEC_COUNT = 4; List<String> ans = new ArrayList<>(); int[] segments = new int[SEC_COUNT]; public List<String> re 阅读全文
posted @ 2020-10-05 10:49 消灭猕猴桃 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 排序 + 双指针 思路: 先将数组排序,再从数组中取出一个元素。使用两个指针从该元素之后取出一小一大两个元素,如果当前三个元素相加不为0,那么调整两个指针的位置继续求和。如果为0则将三个元素加入结果中。 class Solution { public List<List<Integer>> thre 阅读全文
posted @ 2020-10-04 16:02 消灭猕猴桃 阅读(60) 评论(0) 推荐(0) 编辑
摘要: 暴力法 class Solution { public int[] corpFlightBookings(int[][] bookings, int n) { int[] ans = new int[n]; for (int i = 0; i < bookings.length; i++) { fo 阅读全文
posted @ 2020-10-03 19:03 消灭猕猴桃 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 动态规划 使用一个二维数组记录每个位置的最大宽度,这样就能在线性时间内计算得到以该点为右下角的最大矩形。 class Solution { public int maximalRectangle(char[][] matrix) { if (matrix.length == 0) return 0; 阅读全文
posted @ 2020-10-02 10:49 消灭猕猴桃 阅读(66) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 39 下一页