![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
基础算法
文章平均质量分 68
爱笑的Gary哥
这个作者很懒,什么都没留下…
展开
-
455 分发饼干
455 分发饼干很简单的贪心题目假设你是一位很棒的家长,想要给你的孩子们一些小饼干。但是,每个孩子最多只能给一块饼干。对每个孩子 i,都有一个胃口值 g[i],这是能让孩子们满足胃口的饼干的最小尺寸;并且每块饼干 j,都有一个尺寸 s[j] 。如果 s[j] >= g[i],我们可以将这个饼干 j 分配给孩子 i ,这个孩子会得到满足。你的目标是尽可能满足越多数量的孩子,并输出这个最大数值。示例 1:输入: g = [1,2,3], s = [1,1]输出: 1解释:你有三个孩子和原创 2021-03-30 20:19:58 · 130 阅读 · 2 评论 -
Insert element in an array
def insert(lst, i, e):"""lst:一个数组或向量,Python 就用 list 表达吧i:待插入元素的位置e:待插入元素"""##补全代码#Subscript processing: the absolute value of positive/negative numbers is greater than the length of the array, it is added to the end and first position of the arr原创 2020-07-13 22:09:41 · 246 阅读 · 0 评论 -
Hailstone
It is an interesting problem in professor Deng’s Mooc.**Here is the code for Hailstone. **def hailstone(n): length = 1 while(1 < n): if n % 2 == 0: n = n/2 else: n = n*3 + 1 length += 1 return lengthIt is quite easy to understand! How原创 2020-07-13 21:46:47 · 261 阅读 · 0 评论 -
Basic elements of the algorithm
What is the algorithm?Is the program equal to the algorithm?Here is a MOOC recommend to you by Professor Deng from Tsinghua University. Data StructureI give you some excerpts:Actually,the characteristics of algorithm include but are not limited to thes原创 2020-07-12 22:44:25 · 195 阅读 · 0 评论 -
Selection Sorting
We use some simple pictures to introduceYou can watch the animation on this website VisualizationHere is the code written in python with some useful annotate and optimization# -*- coding: utf-8 -*-"""Created on Sun Jul 12 21:22:33 2020@author: Gary原创 2020-07-12 22:29:03 · 175 阅读 · 0 评论 -
Bubble Sort
IntroductionFor most people, Bubble Sort is likely the first sorting algorithm they heard of in their Computer Science course.It’s highly intuitive and easy to “translate” into code, which is important for new software developers so they can ease themsel原创 2020-07-07 22:25:34 · 154 阅读 · 0 评论