大道至简

人生苦短,我用Python.

Linux创建特定用户运行应用程序

创建特定用户运行应用程序

1. 运行用户空间应用程序 我们知道Linxu分为内核态和用户态,用户态和内核态交互的桥梁就是shell,用户的应用程序通常运行在用户态,也就是用户空间,默认情况下,root用户拥有系统最高权限,很多时候我们在linux部署应用程序时,程序可能需要取得某些系统权限才能正常运行,比如在所属组为root的目录里新建一个*.pid文件,普通用户是没有权限的,所以我们一般直接使用root用户来运行...

LeetCode-516. Longest Palindromic Subsequence

LeetCode-516. Longest Palindromic Subsequence

1、题目 Given a string s, find the longest palindromic subsequence’s length in s. You may assume that the maximum length of s is 1000. Example 1: Input: "bbbab" Output: 4 One possible longest palin...

LeetCode-698. Partition to K Equal Sum Subsets

LeetCode-698. Partition to K Equal Sum Subsets

1、题目 Given an array of integers nums and a positive integer k, find whether it’s possible to divide this array into k non-empty subsets whose sums are all equal. Example 1: Input: nums = [4, 3, ...

LeetCode-1027. Longest Arithmetic Sequence

LeetCode-1027. Longest Arithmetic Sequence

1、题目 Given an array A of integers, return the length of the longest arithmetic subsequence in A. Recall that a subsequence of A is a list A[i_1], A[i_2], …, A[i_k] with 0 <= i_1 < i_2 < ...

LeetCode-673. Number of Longest Increasing Subsequence

LeetCode-673. Number of Longest Increasing Subsequence

1、题目 Given an unsorted array of integers, find the number of longest increasing subsequence. Example 1: Input: [1,3,5,4,7] Output: 2 Explanation: The two longest increasing subsequence are [1, 3,...

LeetCode-Bomb Enemy

LeetCode-Bomb Enemy

1、题目 有一个M*N的网格,每一个格子可能为空,可能有一个敌人,可能有一堵墙,空格子使用'0'表示,敌人用'E'表示,墙使用'W'表示. 只能在某个空格子里放一个炸弹,炸弹会炸死网格所在同行同列的敌人,但是不能穿透墙, 最多能炸死多人敌人? 2、思路 这是一道坐标型动态规划的题,我们可以按照下面四步来分析: 2.1、确定状态 首先分析一个方向(向上) 假设在网格的每一个格子都可...

LeetCode-931. Minimum Falling Path Sum

LeetCode-931. Minimum Falling Path Sum

1、题目 Given a square array of integers A, we want the minimum sum of a falling path through A. A falling path starts at any element in the first row, and chooses one element from each row. The ne...

动态规划-Coin Change

Coin Change

1、题目 You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount ...

LeetCode-746-Min Cost Climbing Stairs

LeetCode-746-Min Cost Climbing Stairs

1、题目 On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach th...

LeetCode-Alg-1005-Maximize Sum Of Array After K Negations

LeetCode-Alg-1005-Maximize Sum Of Array After K Negations

1、题目 Given an array A of integers, we must modify the array in the following way: we choose an i and replace A[i] with -A[i], and we repeat this process K times in total. (We may choose the same ...