![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
我的笔试
文章平均质量分 78
灯火星星
这个作者很懒,什么都没留下…
展开
-
串的模式匹配
在源字符串中查找目标串的位置,要求: 1,使用回溯法; 伪代码: 输入:主串S,模式T 输出:T在S中的位置 1.初始化主串比较的开始位置index=0; 2.在串S和串T中设置比较的起始下标i=0,j=0; 3.重复下述操作,直到S或T的所有字符均比较完毕: 3.1如果S[i]等于T[j],则继续比较S和T的下一对字符; 3.2否则,下一趟匹配的开始位置index++,回溯下标i=index,j=0; 4.如果T中所有字符均比较完,则返回匹配的开始位置index;否则返回0; 算法主体: 测试用例:原创 2020-07-14 20:54:38 · 595 阅读 · 0 评论 -
给一些特定的零钱,输出张数最小的方案。
package 笔试; import java.util.Scanner; public class 最小钱币方案问题 { static int RMB[]= {1,2,5,10,20,50,100}; public static void main(String[] args) { // TODO Auto-generated method stub Scanner in=new Scanner(System.in); while(in.hasNext()) { int n=i原创 2020-07-14 18:24:16 · 346 阅读 · 0 评论 -
力扣第5题只出现一次的数字
class Solution { public int singleNumber(int[] nums) { int result=0; for(int i=0;i<nums.length;i++) result ^=nums[i]; return result; } }原创 2020-07-14 17:12:39 · 143 阅读 · 0 评论 -
大厂2021秋招笔试题目把链表相邻元素反转
把链表相邻元素反转 `#include “iostream” using namespace std; struct ListNode { int mVlaue; ListNode* pNext; }; ListNode* reverseList(ListNode* head) { if (headNULL || head->pNextNULL) return head; ListNode pre = head,cur = head->pNext,next = NULL; while (cur!原创 2020-07-14 16:22:54 · 123 阅读 · 0 评论