![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode刷题
Markland_l
这个作者很懒,什么都没留下…
展开
-
148. 排序链表
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) { this.val = val; this.next = next; } * }原创 2021-05-03 21:10:25 · 69 阅读 · 0 评论 -
769. 最多能完成排序的块
class Solution { public int maxChunksToSorted(int[] arr) { int count = 0; int max = 0; for(int i=0;i<arr.length;i++){ for(int j=0;j<=i;j++){ max = Math.max(max,arr[j]); }原创 2021-05-03 01:39:13 · 98 阅读 · 0 评论 -
419. 甲板上的战舰
class Solution { public int countBattleships(char[][] board) { int res = 0; for(int i=0;i<board.length;i++){ for(int j=0;j<board[0].length;j++){ if(board[i][j]=='X'){ res++;原创 2021-05-02 12:38:10 · 63 阅读 · 0 评论 -
1493. 删掉一个元素以后全为 1 的最长子数组
class Solution { public int longestSubarray(int[] nums) { int last = 0; int cur = 0; int res = 0; int flag = 0; for(int i=0;i<nums.length;i++){ if(nums[i]==1){ cur += 1;原创 2021-05-01 23:58:46 · 73 阅读 · 0 评论 -
96. 不同的二叉搜索树
class Solution { public int numTrees(int n) { int[] dp = new int[n+1]; dp[0] = 1; dp[1] = 1; for(int i=2;i<=n;i++) for(int j=0;j<=i-1;j++){ dp[i] += dp[j]*dp[i-j-1]; }原创 2021-05-01 12:11:23 · 52 阅读 · 0 评论 -
1167. 连接棒材的最低费用
class Solution { public int connectSticks(int[] sticks) { int sum = 0; if (sticks.length==0 || sticks.length==1){ return 0; } Queue<Integer> queue = new PriorityQueue(); for (int i = 0; i < sticks.length; i++) {原创 2021-04-29 23:42:12 · 91 阅读 · 0 评论 -
2. 两数相加
/** Definition for singly-linked list. public class ListNode { int val; ListNode next; ListNode() {} ListNode(int val) { this.val = val; } ListNode(int val, ListNode next) { this.val = val; this.next = next; } } */ class Solution { pub原创 2021-04-23 19:00:04 · 71 阅读 · 0 评论 -
leetcode
参考地址 https://github.com/yuanguangxin/LeetCode https://blog.csdn.net/lingpy/article/details/88085446 https://blog.csdn.net/CowBoySoBusy/article/details/82559651原创 2020-12-08 01:41:55 · 112 阅读 · 0 评论