![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
酸乳酸乳
这个作者很懒,什么都没留下…
展开
-
leetcode滑动窗口练习
3.无重复最长子序列对于这样的题,一定要计算好窗口的长度class Solution { public int lengthOfLongestSubstring(String s) { if(s.length()<=1){ return s.length(); } int sum = 0; int max = -1; int start = 0; for(int i=0;原创 2021-09-16 19:13:43 · 55 阅读 · 0 评论 -
leetcode 链表练习
这几天面试编程总是出现问题,确实是自己的问题,没有好好练习,在面试的时候一定要注意心态,不要紧张。83 将重复元素删除,只留一个class Solution { public ListNode deleteDuplicates(ListNode head) { if(head==null){ return head; } ListNode p = head; while(p!=null&&p.原创 2021-09-16 19:09:55 · 106 阅读 · 0 评论 -
leetcode25 + java
class Solution { public static ListNode reverseKGroup(ListNode head, int k) { if(k==1){ return head; } ListNode left = new ListNode(); left = head; ListNode right = head; ListNode temp;原创 2021-09-10 21:58:15 · 66 阅读 · 0 评论 -
leetcode37 + java
数独回溯使用三个数组记录状态 行 列 九宫格class Solution { public boolean[][] v1 = new boolean[9][10]; public boolean[][] v2 = new boolean[9][10]; public boolean[][] v3 = new boolean[9][10]; public void solveSudoku(char[][] board) { for(int i=0;i&l原创 2021-09-10 20:06:39 · 72 阅读 · 0 评论 -
leetcode32 最长有效括号 + java
主要设置了一个标志位数组,把匹配的位置值为true,最后统计最长连续长度就可以了class Solution { public int longestValidParentheses(String s) { int sum = 0; int left = 0; boolean[] b = new boolean[s.length()]; int max = Integer.MIN_VALUE; for(int i=0;原创 2021-09-10 18:14:39 · 60 阅读 · 0 评论 -
leetcode上面的Tree合集
leetcode上面的Tree合集100.SameTree100.SameTree判断两棵树是否是一样的二叉树# Definition for a binary tree node.# class TreeNode:# def __init__(self, x):# self.val = x# self.left = None# ...原创 2019-09-21 16:17:17 · 122 阅读 · 0 评论 -
leetcode 判断链表是否有环
# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: def hasCycle(self, head: ListNode) -> ...原创 2019-09-18 21:35:23 · 96 阅读 · 0 评论 -
链表反转
使用python实现单链表的反转leetcode206# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: def reverseLi...原创 2019-09-18 19:29:45 · 78 阅读 · 0 评论 -
leetcode9
判断数字是否是回文,代码如下class Solution { public boolean isPalindrome(int x) { if(x<0) return false; String s=String.valueOf(x); String s1 = new StringBuffer(s).reverse().toStri...原创 2018-09-29 16:56:31 · 73 阅读 · 0 评论 -
leetcode 8
因为心情不太好,好几天没有做题,今天看了一下这道题,觉得还可以,就是一道模拟题,按照题目要求做就好了,其中有一种情况没有考虑到,就是'+','-'。int myAtoi(char* str) { int length = strlen(str); int flag=0; char s1[1005]; int MIN=-2147483648; int M...原创 2018-09-28 11:05:28 · 71 阅读 · 0 评论