题目描述 Sort a linked list in O(n log n) time using constant space complexity. 分析 O(n log n) 的时间复杂度,归并排序最好,因为它不会因…
分类:LeetCode
LeetCode 071 Simplify Path
题目描述 Given an absolute path for a file (Unix-style), simplify it. For example, path = “/home/”, => “/home” …
LeetCode | Reverse Linked List II(翻转链表2)
Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given&…
380. Insert Delete GetRandom O(1)
Medium 这个面经题一做,暴露出来不少基础问题。比如hashmap的key是不能修改的,只能remove旧的再put新的,不可以modify. 还有hashMap的key, value一定要给自己多一点思路空间,就像…
LeetCode: 翻转字符串里的单词
翻转字符串里的单词 题目叙述 给定一个字符串,逐个翻转字符串中的每个单词。 示例: 输入: “the sky is blue”, 输出: “blue is sky the”…
[LeetCode] Linked List Components 链表组件
We are given head, the head node of a linked list containing unique integer values. We a…
[LeetCode] Longest Palindromic Substring 最长回文子串,Palindrome Number,Validate Palindrome,Palindrome Partitioning,Palindrome Partitioning II,Palindrome Partitioning II 拆分回文串之二,Manacher's Algorithm 马拉车算法
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length o…
[LeetCode] Peeking Iterator 顶端迭代器
Given an Iterator class interface with methods: next() and hasNext(), design and impleme…
[LeetCode] Rearrange String k Distance Apart 按距离为k隔离重排字符串
Given a non-empty string str and an integer k, rearrange the string such that the same characters are a…
[LeetCode] Insert Delete GetRandom O(1) 常数时间内插入删除和获得随机数
Design a data structure that supports all following operations in average O(1) time. &nb…
[LeetCode] License Key Formatting 注册码格式化
Now you are given a string S, which represents a software license key which we would like to format. Th…
[Leetcode] Palindrome Permutation 回文变换
Palindrome Permutation Given a string, determine if a permutation of the string could form a palindrome. For e…