大道至简

人生苦短,我用Python.

LeetCode-1053. Previous Permutation With One Swap

LeetCode-1053. Previous Permutation With One Swap

1、题目 Given an array A of positive integers (not necessarily distinct), return the lexicographically largest permutation that is smaller than A, that can be made with one swap (A swap exchanges the...

LeetCode-969. Pancake Sorting

LeetCode-969. Pancake Sorting

1、题目 Given an array A, we can perform a pancake flip: We choose some positive integer k <= A.length, then reverse the order of the first k elements of A. We want to perform zero or more pancak...

LeetCode-1035. Uncrossed Lines

LeetCode-1035. Uncrossed Lines

1、题目 We write the integers of A and B (in the order they are given) on two separate horizontal lines. Now, we may draw connecting lines: a straight line connecting two numbers A[i] and B[j] such ...

LeetCode-Array中几种连续子序列问题总结

LeetCode-Array中几种连续子序列问题总结

1 和能被K整除的子数组个数 1.1 题目 Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K. Example 1: Input: A = [4,5,0,-2,-3,1], K = 5 Output: 7 ...

LeetCode-974. Subarray Sums Divisible by K

LeetCode-974. Subarray Sums Divisible by K

1、题目 Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K. Example 1: Input: A = [4,5,0,-2,-3,1], K = 5 Output: 7 Explanation: Ther...

LeetCode-109. Convert Sorted List to Binary Search Tree

LeetCode-109. Convert Sorted List to Binary Search Tree

1、题目 Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is defined as a binary tree in w...

LeetCode-142. Linked List Cycle II

LeetCode-142. Linked List Cycle II

1、题目 Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To represent a cycle in the given linked list, we use an integer pos which represents the posi...

LeetCode-148. Sort List

LeetCode-148. Sort List

1、题目 Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->1->3 Output: 1->2->3->4 Example 2: Input: -1->5->3->4->0 ...

Linux三剑客-sed

sed命令使用

1.什么是sed sed是一个流编辑器,它以行为单位处理文本,文本可以来自文件、标准输入等,sed将文本的一行存储到临时缓冲区,称为”模式空间”, 并使用sed命令对缓冲区内容进行操作,处理完成后将缓冲区内容通过终端显示,接着处理下一行,直到文件末尾,sed不会修改文本内容,除非使用-i参数或重定向存储输出。 2.参数及其含义 sed [-nefilr] [动作] ...

LeetCode-120. Triangle

LeetCode-120. Triangle

1、题目 Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [2], [3,4],...