leetcode_easy_array problem 1486. XOR Operation in an Array solution #1: code: 参考 1. leetcode_1486. XOR Operation in an Array; 完 ...
分类:
其他好文 时间:
2020-10-30 12:53:24
阅读次数:
17
当我按照官方的思路写出代码,提交后并未通过,查看错误,发现算法错误的将[2147483647,-2147483648]也视为连续的整数了,这是因为我没有考虑到int类型的边界。将代码稍加修改,即成功提交 //哈希表,建议看官方的题解,尤其是演示动画 class Solution { public i ...
分类:
其他好文 时间:
2020-10-29 10:20:41
阅读次数:
23
//通过哈希表来查重 class Solution { public boolean containsDuplicate(int[] nums) { Set<Integer> set = new HashSet<>(); for(int i = 0;i < nums.length;i++){ if( ...
分类:
其他好文 时间:
2020-10-29 10:06:06
阅读次数:
17
一.题源 https://www.lintcode.com/problem/permutations-ii/description https://leetcode-cn.com/problems/permutations-ii/ 二.代码分析 1 public class Solution { 2 ...
分类:
其他好文 时间:
2020-10-27 11:42:13
阅读次数:
24
class Solution { public List<Integer> postorderTraversal(TreeNode root) { //一般解法,前序遍历后,翻转下结果集,注意下 与前序遍历的进栈顺序不一样 //(前序) 根左右 --> 变为 根右左 --> 翻转 左右根 (后续) ...
分类:
其他好文 时间:
2020-10-27 11:40:04
阅读次数:
20
嵌套(Nesting)Less 提供了使用嵌套(nesting)代替层叠或与层叠结合使用的能力。假设我们有以下 CSS 代码: #header { color: black;}#header .navigation { font-size: 12px;}#header .logo { width: ...
分类:
其他好文 时间:
2020-10-27 11:17:08
阅读次数:
21
1 class Solution: 2 def longestMountain(self, A: List[int]) -> int: 3 n = len(A) 4 left = [0] * n # 初始化 5 for i in range(1, n): 6 left[i] = (left[i - ...
分类:
其他好文 时间:
2020-10-26 11:28:01
阅读次数:
20
响应 Rsponse 当一个请求完成后,我们一般都会返回drf中的Rsponse对象,那么该对象其中最重要的作用就是序列化。 将需要返回给页面的数据进行JSON处理,除此之外还会对返回的页面等进行包装,它的内部其实也挺有趣儿的。 下面是Rsponse的签名: def __init__(self, d ...
分类:
其他好文 时间:
2020-10-26 11:24:30
阅读次数:
24
#剑指 Offer 47. 礼物的最大价值 解题思路 因为对于一个点,只可能是从上方或左方累加过来,那么选择值最大的那个方向累加即可。 转移方程: f[i][j]+=max(f[i-1][j],f[i][j-1]); 在原矩阵上操作,最后返回最右下角的数即可。 代码 class Solution { ...
分类:
其他好文 时间:
2020-10-26 11:22:21
阅读次数:
20
题目介绍 判断给定二叉树是否为一棵二叉搜索树。 Examples: 2 / \ 1 3 Input: [2,1,3] Output: true 5 / \ 1 4 / \ 3 6 Input: [5,1,4,null,null,3,6] Output: false Solution 仅仅使用递归判断 ...
分类:
其他好文 时间:
2020-10-26 11:18:28
阅读次数:
24