数据结构

排序:
https://leetcode-cn.com/problems/shortest-unsorted-continuous-subarray/
二分查找
https://leetcode-cn.com/problems/binary-search/
【】二分搜索
https://leetcode-cn.com/problems/search-insert-position/
【】二分搜索+为-1时返回应插入的位置
二叉搜索树
https://leetcode-cn.com/problems/search-in-a-binary-search-tree/
https://leetcode-cn.com/problems/trim-a-binary-search-tree/
【】https://blog.csdn.net/hy971216/article/details/81570498
【】https://blog.csdn.net/LSGO_MYP/article/details/92796893
https://leetcode-cn.com/problems/range-sum-of-bst/
【】https://blog.csdn.net/qq_17550379/article/details/84034131
https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-search-tree/ 【】https://www.cnblogs.com/eilearn/p/9394672.html
https://leetcode-cn.com/problems/find-mode-in-binary-search-tree/
【】中序遍历后求众数
https://leetcode-cn.com/problems/minimum-absolute-difference-in-bst/
【】中序遍历 求相邻元素的差值
https://leetcode-cn.com/problems/minimum-distance-between-bst-nodes/
【】中序遍历
https://leetcode-cn.com/problems/convert-sorted-array-to-binary-search-tree/
【】马老师
二叉树遍历
https://leetcode-cn.com/problems/convert-sorted-array-to-binary-search-tree/
【】马老师
https://leetcode-cn.com/problems/maximum-subarray/solution/hua-jie-suan-fa-53-zui-da-zi-xu-he-by-guanpengchn/
class Solution {
public int maxSubArray(int[] nums) {
int ans = nums[0];
int sum = 0;
for(int num: nums) {
if(sum > 0) {
sum += num;
} else {
sum = num;
}
ans = Math.max(ans, sum);
}
return ans;
}

https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/
【】终止条件、返回值和递归过程:
当前节点root为空时,说明此处树的高度为0,0也是最小值
当前节点root的左子树和右子树都为空时,说明此处树的高度为1,1也是最小值
如果为其他情况,则说明当前节点有值,且需要分别计算其左右子树的最小深度,返回最小深度+1,+1表示当前节点存在有1个深度


https://leetcode-cn.com/problems/unique-paths-ii/
【】无障碍递归
public static int rec_uniquePaths(int m,int n) {
if(m == 1 && n == 1) return 1;
if(m == 1) return rec_uniquePaths(m, n - 1);
if(n == 1) return rec_uniquePaths(m - 1, n);
return rec_uniquePaths(m-1, n) + rec_uniquePaths(m, n - 1);
}
【】有障碍
c# S.Getlength(0)表示行数
class Solution {
public int uniquePathsWithObstacles(int[][] obstacleGrid) {

    int R = obstacleGrid.length;
    int C = obstacleGrid[0].length;

    // If the starting cell has an obstacle, then simply return as there would be
    // no paths to the destination.
    if (obstacleGrid[0][0] == 1) {
        return 0;
    }

    // Number of ways of reaching the starting cell = 1.
    obstacleGrid[0][0] = 1;

    // Filling the values for the first column
    for (int i = 1; i < R; i++) {
        obstacleGrid[i][0] = (obstacleGrid[i][0] == 0 && obstacleGrid[i - 1][0] == 1) ? 1 : 0;
    }

    // Filling the values for the first row
    for (int i = 1; i < C; i++) {
        obstacleGrid[0][i] = (obstacleGrid[0][i] == 0 && obstacleGrid[0][i - 1] == 1) ? 1 : 0;
    }

    // Starting from cell(1,1) fill up the values
    // No. of ways of reaching cell[i][j] = cell[i - 1][j] + cell[i][j - 1]
    // i.e. From above and left.
    for (int i = 1; i < R; i++) {
        for (int j = 1; j < C; j++) {
            if (obstacleGrid[i][j] == 0) {
                obstacleGrid[i][j] = obstacleGrid[i - 1][j] + obstacleGrid[i][j - 1];
            } else {
                obstacleGrid[i][j] = 0;
            }
        }
    }

    // Return value stored in rightmost bottommost cell. That is the destination.
    return obstacleGrid[R - 1][C - 1];
}

}

单元最短路径
https://blog.csdn.net/ccnuacmhdu/article/details/78765648


https://leetcode-cn.com/problems/valid-palindrome/
【】将所给字符串筛选后判断是否为回文串

https://leetcode-cn.com/problems/longest-palindrome/
找出字符串中每个字符出现的次数
若字符出现次数为奇数次,出现的次数减去1则为可用于构造回文串的字符数。若出现的次数为偶数次,出现次数则为可用于构造回文串的字符数
若存在奇数次字符,则最终结果再+1,因为奇数字符可放一个在最中间

https://leetcode-cn.com/problems/find-all-anagrams-in-a-string/
【】在串中找出所有与所给串的长度相同的串

https://leetcode-cn.com/problems/repeated-substring-pattern/
【】将字符串加起来,判断中间是否会存在这个字符串

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

聆一

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值