解题思路: 动态规划 注意要初始化第一行和第一列的值 class Solution {public int uniquePaths(int m, int n) {int[][] dp = new int[m][n];for (int i = 0; i < m; i++) {dp[i][0] = 1;}for (int j = 0; j < n; j++) {dp[0][j]
解题思路: 栈 class Solution {public int longestValidParentheses(String s) {int max = 0;// 也可以使用 Stack<Integer> stack=new Stack<>();但Stack是遗留类,不推荐Deque<Integer> stack = new LinkedList<>();stack.push(-1)
基础知识要求: Java:方法、while循环、for循环、if else语句 Python: 方法、while循环、for循环、if else语句 题目: 给你链表的头节点 head ,每 k 个节点一组进行翻转,请你返回修改后的链表。 k 是一个正整数,它的值小于或等于链表的长度。如果节点总数不是 k 的整数倍,那么请将最后剩余的节点保持原有顺序。 你不能只是单纯的改
解题思路: class Solution {public List<Integer> partitionLabels(String s) {int[] last = new int[26];int len = s.length();for (int i = 0; i < len; i++) {last[s.charAt(i) - 'a'] = i;//记录字母最远的下标}List