随笔分类 -  模拟题

摘要:题目来源 补充题9. 36进制加法 题目详情 36进制由0-9,a-z,共36个字符表示。 要求按照加法规则计算出任意两个36进制正整数的和,如1b + 2x = 48 (解释:47+105=152) 要求:不允许使用先将36进制数字整体转为10进制,相加后再转回为36进制的做法 相似题目 415. 阅读全文
posted @ 2022-04-01 16:51 Garrett_Wale 阅读(571) 评论(0) 推荐(0) 编辑
摘要:题目来源 43. 字符串相乘 题目详情 给定两个以字符串形式表示的非负整数 num1 和 num2,返回 num1 和 num2 的乘积,它们的乘积也表示为字符串形式。 示例 1: 输入: num1 = "2", num2 = "3" 输出: "6" 示例 2: 输入: num1 = "123", 阅读全文
posted @ 2022-01-23 17:13 Garrett_Wale 阅读(27) 评论(0) 推荐(0) 编辑
摘要:468. 验证IP地址 LeetCode_468 题目描述 方法一:正则表达式 import java.util.regex.*; class Solution { //Ipv4的正则匹配表达式 String regIpv4 = "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0- 阅读全文
posted @ 2021-03-30 10:29 Garrett_Wale 阅读(100) 评论(0) 推荐(0) 编辑
摘要:54. 螺旋矩阵 LeetCode_54 相似题目:剑指 Offer 29. 顺时针打印矩阵 题目描述 代码实现 class Solution { public List<Integer> spiralOrder(int[][] matrix) { int m = matrix.length;//行 阅读全文
posted @ 2021-03-07 20:23 Garrett_Wale 阅读(111) 评论(0) 推荐(0) 编辑
摘要:415. 字符串相加 LeetCode_415 题目详情 方法一:使用暴力法 class Solution { public String addStrings(String num1, String num2) { int len1 = num1.length(); int len2 = num2 阅读全文
posted @ 2021-03-06 21:44 Garrett_Wale 阅读(97) 评论(0) 推荐(0) 编辑
摘要:剑指 Offer 30. 包含min函数的栈 Offer_30 题目描述: 相似题目 剑指 Offer 30. 包含min函数的栈 面试题59 - II. 队列的最大值 155. 最小栈 题解分析: 题目其实考察的是栈的知识,本题的目的是使用两个栈来求解最小值。 第二个栈主要用来维护第一个栈中的最小 阅读全文
posted @ 2021-01-31 14:12 Garrett_Wale 阅读(94) 评论(0) 推荐(0) 编辑
摘要:剑指 Offer 29. 顺时针打印矩阵 Offer_29 题目描述: 题解分析: 题目的初衷是将这道题当做一个简单题处理 这道题一开始想的太复杂了,其实可以参考迷宫广度优先搜索的过程,只不过在选定一个方向遍历时,除非遇到改变方向的情况,否则一直走下去。 需要注意的是:这里的方向二维数组(direc 阅读全文
posted @ 2021-01-31 13:27 Garrett_Wale 阅读(78) 评论(0) 推荐(0) 编辑
摘要:Travelling Salesman Problem PAT-1150 #include<iostream> #include<cstring> #include<string> #include<algorithm> #include<cstdio> #include<sstream> #inc 阅读全文
posted @ 2020-09-22 18:20 Garrett_Wale 阅读(140) 评论(0) 推荐(0) 编辑
摘要:Decode Registration Card of PAT PAT-1153 这里需要注意题目的规模,并不需要一开始就存储好所有的满足题意的信息 这里必须使用unordered_map否则会超时 vector的使用需要注意,只有一开始赋予了容量才能读取。 不需要使用set也可以 #include 阅读全文
posted @ 2020-09-21 17:58 Garrett_Wale 阅读(121) 评论(0) 推荐(0) 编辑
摘要:小计算器 "PREV 55" 这题我使用的是java来求解,因为这题需要求解各种进制的转换。可以利用valueOf和toString来转换各种进制。 值得注意的是:这题有很多细节,因为有的命令之间不是必然连续的,所以需要处理。 我一开始总是运行错误,后来发现这是漏写了一个flag的情况。 阅读全文
posted @ 2020-03-13 10:33 Garrett_Wale 阅读(311) 评论(0) 推荐(0) 编辑
摘要:宝石与石头 "LeetCode 771" 使用哈希表。 这里使用内置算法库中的map 阅读全文
posted @ 2020-02-25 20:18 Garrett_Wale 阅读(126) 评论(0) 推荐(0) 编辑
摘要:JSON查询 "201709 3" 纯字符串模拟,考的就是耐心和细心。可惜这两样我都缺。。。 include include include include include include include using namespace std; const int maxn=102; int n, 阅读全文
posted @ 2019-09-03 19:39 Garrett_Wale 阅读(228) 评论(0) 推荐(0) 编辑
摘要:公共钥匙盒 "201709 2" 这题的思路一开始不是很清晰,一开始想用贪心去做。但是发现按照题目的思路不对。所以这里采用的是类似于多项式的加减的处理。 include include include include include include include using namespace s 阅读全文
posted @ 2019-09-03 16:21 Garrett_Wale 阅读(289) 评论(0) 推荐(0) 编辑
摘要:URL映射 "CCF201803 3" include include include include include include include include include using namespace std; const int maxn=101; const int maxm=10 阅读全文
posted @ 2019-09-01 20:39 Garrett_Wale 阅读(204) 评论(0) 推荐(0) 编辑
摘要:quailty and ccpc "hdoj 6666" 题目很简单,按照题目的意思模拟就行了,排序。 include include include include include using namespace std; struct node{ string name; int num; in 阅读全文
posted @ 2019-08-18 20:19 Garrett_Wale 阅读(120) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示