Given an array arr that is a permutation of [0, 1, ..., arr.length - 1], we split the ar…
分类:LeetCode
83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1: Input: 1…
Leetcode. Maximum Size Subarray Sum <= k
给定一个无序数组arr, 其中元素可正, 可负, 可0, 给定一个整数k. 求arr所有的子数组中累加和小于或等于k的最长子数组长度. 例如: arr[] = {3, -2, -4, 0, 6}, k=2 相加和小于或等…
[LeetCode][Python]461. Hamming Distance
The Hamming distance between two integers is the number of positions at which the corresponding bits are diffe…
9. 回溯
套路很深,就是遍历全部情况 定义解空间,包含全部解 利用深度优先搜索解空间 Trial,减枝。(避免访问不可能产生解的子空间) 而根据条件有选择的遍历,叫做剪枝或分枝定界。 主要分为2中情况: 宽度不定,解空间大小通常为…
Leetcode之369-链表加1
前言 个人网站 公众号: 北京程序猿, 网站 : https://yaml.vip 算法题 题干 Given a non-negative number represented as a singly linked li…
Leetcode - Rearrange String k Distance Apart
My code: public class Solution { public String rearrangeString(String str, int k) { if (str == null) { return …
23. Merge k Sorted Lists
欢迎fork and star:Nowcoder-Repository-github 23. Merge k Sorted Lists 题目 Merge k sorted linked lists and return …
[LeetCode] Symmetric Tree 判断对称树
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For exam…
[LeetCode] Logger Rate Limiter 记录速率限制器
Design a logger system that receive stream of messages along with its timestamps, each message should b…
LeetCode | Evaluate Reverse Polish Notation
题目: Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +…
[Leetcode] 3Sum 4Sum 3Sum Closet 多数和
2Sum 在分析多数和之前,请先看Two Sum的详解 3Sum 请参阅:https://yanjia.me/zh/2019/01/… 双指针法 复杂度 时间 O(N^2) 空间 O(1) 思路 3Sum其实…