摘要:
Question Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index. 阅读全文
摘要:
Question There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank an 阅读全文
摘要:
Question Given two strings text1 and text2, return the length of their longest common subsequence. A subsequence of a string is a new string generated 阅读全文
摘要:
Question Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. 即求最长回文子串(注意和最长回文子序列的区别,子串 阅读全文
摘要:
Question Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Example 1: Input: 阅读全文
摘要:
python中乘号*常被用于快速初始化list,但有一个隐患: 被乘号复制的对象都指向同一个空间。当被复制对象为不可变类型时,不会出现问题,但当当被复制对象为可变类型时,若有一个引用改变这块存储空间,其他引用该存储空间的列表也会发生改变。 用id()可以验证其指向的空间 所以更安全的创建初始化lis 阅读全文
摘要:
错误示范 写python时常常会遇到想删除list中的特定值的元素的情况,但如果用一个循环遍历的话显然是行不通的,比如 或者 都会出现问题,因为pop()或remove()之后list已经发生改变,继续迭代会出现问题。 因此,由于list底层基于线性表(数组)的特性,不能使用这种方法删除,要用其他方 阅读全文
摘要:
如,要 kill 掉进程信息中匹配到 swoole 相关的进程 ps aux | grep swoole | awk '{print $2}' | xargs kill -9 ps 列出所有进程 a - 显示现行终端机下的所有进程,包括其他用户的进程; u - 以用户为主的进程状态 ; x - 通常 阅读全文