![](https://img-blog.csdnimg.cn/2019091813595558.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
数据结构与算法
文章平均质量分 56
一些布置的习题。
ShinowXD
在秃了在秃了。
展开
-
数据结构 | SORT | Largest Number
题目Given a list of non negative integers, arrange them such that they form the largest number.Example 1:Input: [10,2]Output: “210”Example 2:Input: [3,30,34,5,9]Output: “9534330”【输入】n个非负数,n大于1小于1000,序列n长度小于1000;【输出】n个非负数组成的最大值。例如:【输入】3 30 34 5 9原创 2022-05-02 20:34:49 · 606 阅读 · 0 评论 -
数据结构 | SORT | Merge Intervals
题目Given a collection of intervals, merge all overlapping intervals.Example 1:Input: [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6].Example 2:Input: [[1,4],[4,5],原创 2022-05-02 20:23:50 · 330 阅读 · 0 评论 -
数据结构 | List | Binary_search
题目(二分查找的实现)请尝试用你实现的顺序存储List实现二分查找。List中的Record包含key和other部分。其中key为英文单词,other为单词的中文解释。【输入】第一行,查询目标target(英文单词)第二行,若干条包含key(string)和other(string)的序列,序列按照key的升序排列;(单词数量小于2000)【输出】查询目标所在的下标,查询目标的内容(key和other),若单词不存在则输出-1即可。例如【输入】waitcomputer 电脑 eye 眼睛原创 2022-04-21 18:49:12 · 1068 阅读 · 0 评论 -
数据结构 | 队列 | 团队队列
题目有t个团队的人正在排一个长队。每次新来一个人时,如果他有队友在排队,那么这个新人会插队到最后一个队友的身后。如果没有任何一个队友排队,则他会排到长队的队尾。输入要求支持如下指令:ENQUEUE x y:x团队编号为y的人进入长队。DEQUEUE:长队的队首出队。STOP:停止模拟对于每个DEQUEUE指令,输出出队的人的编号。【输入】输入数据包含多个测试样例,输入的每个样例第一行为团队数t(1<=t<=10),团队编号为1…t,接着的每行输入操作指令。当输入指令为STOP时,结束原创 2022-04-06 22:51:31 · 830 阅读 · 2 评论 -
数据结构 | 链表 | 约瑟夫问题
题目n 个人围成一个圆圈,首先第1个人从1开始一个人一个人顺时针报数, 报到第m个人,令其出列。然后再从下一个人开始,从1顺时针报数,报到第m个人,再令其出列,…,如此下去, 直到圆圈中只剩一个人为止。此人即为优胜者。请用环形链表实现约瑟夫问题。【输入】n(2<=n<=60) m(1<=m)【输出】最后的胜利者编号(编号范围是1至n)例如:【输入】8 3【输出】7分析圆圈->循环列表;出列->队列的删除;报到m->取模运算;只剩一个人->循原创 2022-04-06 21:24:55 · 603 阅读 · 0 评论 -
数据结构 | 递归 | n个数的全排列
数据结构 | 递归 | n个数的全排列题目:给定整数n,n<=10,请求出n的全排列。N=3时,1-3的排列可以为:1:1 2 32:1 3 23:2 1 34:2 3 15:3 1 26:3 2 1一共有6种情况【输入】 整数n,n<=20【输出】1-n的排列 (排列数大于10的,仅输出前10组即可)总的全排列数例如:【输入】 4【输出】1:1 2 3 42:1 2 4 33:1 3 2 44:1 3 4 25:1 4 2 36:1 4 3 27原创 2022-04-06 20:58:49 · 2947 阅读 · 0 评论 -
数据结构 | 递归 | Letter Combinations of a Phone Number
题目:Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.2-.原创 2022-04-06 20:31:07 · 565 阅读 · 0 评论