![](https://img-blog.csdnimg.cn/20190927151124774.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
刷题
文章平均质量分 69
算法刷题
J.Tabibito
这个作者很懒,什么都没留下…
展开
-
Someone‘s Acting Sus....
You are a professional Among Us gamer, however, you don’t know who the impostor is! Luckily, you’re hacking, so you know the exact path each crewmate took before the EMERGENCY MEETING. You notice that certain crewmates are acting SUSSY - they are moving mu原创 2021-10-05 23:17:36 · 149 阅读 · 0 评论 -
Detective-Geek
Detective Geek has a superpower of knowing when and where a crime is going to happen; unfortunately his superpower is encrypted, and he takes a lot of time decrypting it.Everytime he sees a crime using his superpower he starts writing on paper and the res原创 2021-10-04 19:01:15 · 4524 阅读 · 0 评论 -
Ascii-Art
In stations and airports you often see this type of screen:Have you ever asked yourself how it might be possible to simulate this display on a good old terminal? We have: with ASCII art!RulesASCII art allows you to represent forms by using characters.原创 2021-10-04 14:37:07 · 315 阅读 · 0 评论 -
TEMPERATURES
In this exercise, you have to analyze records of temperature to find the closest to zero.Sample temperaturesHere, -1 is the closest to 0.RulesWrite a program that prints the temperature closest to 0 among input data. If two numbers are equally close原创 2021-10-04 14:32:19 · 189 阅读 · 0 评论 -
ASCII Artical:Shadow-Casting
Given an ASCII art pattern, cast a shadow as if the light source is at top-left corner to make the pattern 3D-like.Use hyphen (-) for darker shadow, and backtick (`) for lighter one.Darker shadow is projected by shifting existing pattern 1 character down原创 2021-10-04 14:27:30 · 141 阅读 · 0 评论 -
[LeetCode] Contiguous Array
Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.Example 1:Input: [0,1]Output: 2Explanation: [0, 1] is the longest contiguous subarray with equal...原创 2020-04-22 16:44:26 · 112 阅读 · 0 评论 -
[LeetCode] Backspace String Compare
Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.Note that after backspacing an empty text, the text will continue empty....原创 2020-04-20 14:50:10 · 106 阅读 · 0 评论 -
[LeetCode] Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).You may assume nums1 and num...原创 2020-04-16 14:11:01 · 93 阅读 · 0 评论 -
[LeetCode] Longest Substring Without Repeating Characters
Given a string, find the length of thelongest substringwithout repeating characters.Example 1:Input: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2:...原创 2020-04-15 16:10:58 · 80 阅读 · 0 评论 -
[LeetCode] ThreeSum
Given an arraynumsofnintegers, are there elementsa,b,cinnumssuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not cont...原创 2020-04-14 15:12:38 · 76 阅读 · 0 评论 -
[LeetCode]: Swap Nodes in Pairs方法介绍
Given alinked list, swap every two adjacent nodes and return its head.You maynotmodify the values in the list's nodes, only nodes itself may be changed.Example:Given 1->2->3->4You s...原创 2020-01-14 16:01:13 · 109 阅读 · 0 评论 -
对称平方数
问题描述:打印所有不超过n(n<256)的,其平方具有对称性质的数。如11*11=121。分析:对称性质就是对这个数交换低位和高位,得到新的数和原数相等。解题思路:直接将低位放在高位,高位放低位求解。#include <stdio.h>#include <stdlib.h>#include <string.h>#include <...原创 2019-04-06 21:33:54 · 274 阅读 · 0 评论 -
大数乘法
对于计算机内置整形数据类型,不能存储超过long long的数据。但是可以通过字符串对数据进行相应的转换计算求出结果。#include <stdio.h>#include <stdlib.h>#include <string.h>#include <iostream>#include <string>#include &...原创 2019-04-02 21:25:38 · 81 阅读 · 0 评论 -
分糖果问题
问题描述:有不同分数的小孩排队,怎么分糖果使得糖果数最小,且分数高的小孩分到尽可能多的糖果。分析:每个小孩至少可分到一个糖果,且分数不固定,所以分数高的小孩要尽可能的只比旁边的两个人分的糖果多,而分数低的要尽可能的少。解题思路:分别从前后进行扫描,让每个小孩都能分到糖果,保证分数高的尽可能多于两边的。#include <stdio.h>#include <stdl...原创 2019-04-05 19:12:56 · 1345 阅读 · 0 评论 -
排列问题
问题描述:给出字符串s="abc",求其所有可能的排列。分析:对于一个给定的字符串,其排列公式是A(n,1),n为字符串的长度。解题思路:依次取字符串中的一个字符,然后遍历整个字符串,跳过其本身,再依次取字符对其求排列。问题的关键在于,循环的层数是根据字符串的长度变化的,所以使用递归可以对本题快速求解。#include <stdio.h>#include <std...原创 2019-04-05 19:05:43 · 75 阅读 · 0 评论 -
Nswoj每日一题:街区最短路径问题
[街区最短路径问题]首先,街道分东西方向和南北方向,居民只顺着街道行走;那么采用曼哈顿距离的方法就较为合理: distance(x1,x2);(https://baike.baidu.com/item/%E6%9B%BC%E5%93%88%E9%A1%BF%E8%B7%9D%E7%A6%BB/743092?fr=aladdin)翻译 2017-11-19 16:50:36 · 307 阅读 · 0 评论 -
Nswoj每日一题:Magic Pen
[Magic Pen]原题题意是求一段最长的连续数这些数的和模M能与原数组的和模M能相同,假设原数组和为sum[i],那么其中一段连续数的和为a[i]+a[i+1]+a[i+2]+……+a[j-2]+a[j-1]+a[j] = sum[j] -sum[i-1];那么这段连续数的和的模为(a[i]+a[i+1]+a[i+2]+……+a[j-2]+a[j-1]+a[j] %m),即(sum转载 2017-11-21 16:28:38 · 170 阅读 · 0 评论 -
Nswoj每日一题:括号配对问题
[括号配对]首先可以初始化一个栈,然后执行程序后每次获取一个_sarray字符串中的字符如果是正括号将其压入栈,如果是反括号就取出栈顶元素与其匹配,如果匹配成功则flag++,并将栈顶top--;如果匹配不成功,那么就将flag赋值为0.当所有栈内元素都匹配完成(top == 0)时将结果输出即可.原创 2017-11-16 17:26:47 · 667 阅读 · 0 评论 -
Nswoj每日一题:Binary String Matching
[Binary String Matching]首先计算A,B字符串的长度a_lenth,b_lenth,然后使用A字符串的首元素遍历B字符串的所有元素找出相同的元素;然后用j表示A字符串中的后几个元素i+j为B字符串与A字符串相同的元素开始,依次往后查找a_lenth-1的元素的坐标;每次flag=true时count++,然后flag=false(*如果不让flag=false,会跳过循环再次count++);最后得出结果输出.原创 2017-11-17 10:11:39 · 160 阅读 · 0 评论 -
Nswoj每日一题:水仙花数
[水仙花数]这道题很简单,只要注意运算符的含义就行了.原创 2017-11-23 17:40:07 · 273 阅读 · 0 评论 -
Nswoj每日一题:回文数判断
[回文数]这道题很简单, 直接用两个字符数组保存回文数的左右部分加以判断就可以了下面是部分代码.bool palindrome_optimize(char* letter, int lenth) { char left[MaxLenth] = ""; char right[MaxLenth] = ""; int ml = 0, mr = 0; for (int i = 0, j = len...原创 2018-01-28 14:22:56 · 147 阅读 · 0 评论 -
地图路径
题目描述:从左上角到地图右下角,只能向下或者向右走,求有多少种选择。分析:根据只能向下或者向右移动的条件,可以知道每个点只能有2条可选路径到达下一结点。解题思路: 先将边界设置为1,表示边界只有一种走法。然后对非边界的点进行求和运算(a[i][j] = a[i+1][j] + a[i] + a[j+1])。#include <stdio.h>#include <s...原创 2019-04-04 12:10:33 · 425 阅读 · 0 评论 -
字典问题
问题描述:给定一个字符串s=“catsanddog”, 给出一个字典dict={"cat", "cats", "and", "sand", "dog"}, 求能组成的句式有哪些。例如s=“catsanddog”,dict={"cat", "cats", "and", "sand", "dog"}, sentences=["cat sand dog", "cats and dog"]。分析...原创 2019-04-04 12:20:24 · 669 阅读 · 1 评论 -
分割字符串
问题描述:输入一个字符串s,再输入一个分割长度,按照分割长度将字符串分割成n个子串,输出;如果没有,则输出-1。分析:对字符串按照长度进行分割即可。解题思路:按照顺序遍历字符串,将n个子串分割后放入容器中输出。#include <stdio.h>#include <stdlib.h>#include <string.h>#include &...原创 2019-04-04 12:25:41 · 213 阅读 · 0 评论 -
有序表的合并
问题描述:将两个有序表合并。例如 l1={1,2,3,4,5},l2={2,3,4,5,6} =>l3={1,2,2,3,3,4,4,5,5,6}。分析:将两个有序表合并,就是归并的过程。解题思路:实现归并排序的归并过程即可。#include <stdio.h>#include <stdlib.h>#include <string.h>...原创 2019-04-04 12:29:56 · 481 阅读 · 0 评论 -
Nswoj每日一题:一种排序
[一种排序]首先使用结构体保存这个长方形的特点(编号,长,宽);然后输入每个信息同时对长宽进行位置交换(保证长>宽);使用sort函数对(0,m)区间内的所有长方形按照Judge()的规则进行排序;最后用tem1,tem2,tem3保存每个长方形的信息与所有长方形比较,如果不同就打印;*(因为之前已经做过排序所以相同的长方形已经在相邻的区间内,所以不会打印出来相同的长方形);原创 2017-11-18 13:16:23 · 260 阅读 · 0 评论