- 博客(3)
- 收藏
- 关注
原创 Leetcode算法做题记录(二)
题目7解法1【算法思路】:① 使用列表,将输入数字的每一位从个位起依次存入列表;② 对列表中的0元素进行处理,然后将列表的元素变为数字输出;③ 根据条件返回对应的翻转数字;④ 算法复杂度为O(n),较高。【代码】:class Solution: def reverse(self, x): """ type x: int rtype : int """ nums = [] if x ==
2021-03-21 19:53:24 95
原创 Leetcode算法做题记录(一)
题目1:Two Sum解法1【算法思路】:① 使用列表,对列表中的每个元素依次进行遍历;② 将当前遍历元素之外的元素作为新的列表,判断其中是否有符合条件的输出。③ 算法复杂度为O(n)【代码】:class Solution(object): def twoSum(self, nums, target): """ type nums: List[int] type target: int rtype: List[int]
2021-03-18 21:49:02 130 3
原创 AcWing基础算法(一)
一、排序快速排序思想:基于分治。算法步骤:① 确定分界点 x(边界点、中间点、随机点 —— 数值;② 调整区间:使得所有 ≤ x 的数在 x 的左边,所有 ≥ x 的数在 x 右边;③ 递归处理左右两段;void quick_sort(int q[], int l, int r){ if (l >= r) return; int x = q[l], i = l - 1, j = r + 1; //确定分界点和指针 while (i < j) { do i
2021-03-04 11:07:00 2081 5
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人