![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构与算法
broccoli2
这个作者很懒,什么都没留下…
展开
-
在字符串尾部/头部加入最少字符使字符串成为回文字符串
2021某易笔试题:给定一个字符串,判断其是否为回文串,若不是回文串的话在该串头部添加任意字符使其成为回文串。 本文参考了[1] 并实现了两种方式,一种为在字符串头部添加任意字符,另一种为在字符串尾部添加任意字符。 1.在字符串头部添加任意字符,使其成为回文串。 package com.cd.utils; import java.util.Scanner; public class Demo { public static void main(String[] args) { Scanner原创 2020-08-13 15:21:56 · 2355 阅读 · 0 评论 -
找出一段文本中所有长度大于5的回文串
今儿朋友阿里三面,有这么一道题。 题目描述: 打印出一段文本中的所有长度大于5的回文串,请用你熟悉的语言编码。 先给出Java语言的,后面又时间会给出python的版本。 Java实现: package com.cd.utils; import java.util.ArrayList; import java.util.List; public class Test { public ...原创 2020-04-12 16:36:36 · 473 阅读 · 0 评论 -
数据结构----选择排序
具体解释不说了,直接上代码。 public class SelectSort { public static void main(String[] args) { int[] array = {23,10,7,12,5,1}; System.out.print("排序前;"); printArray(array); selectA原创 2017-06-22 21:45:16 · 235 阅读 · 0 评论 -
水仙花数
水仙花数(Narcissistic number)也被称为超完全数字不变数(pluperfect digital invariant, PPDI)、自恋数、自幂数、阿姆斯壮数或阿姆斯特朗数(Armstrong number),水仙花数是指一个 n 位数(n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身(例如:1^3 + 5^3+ 3^3 = 153)。#include<iostream>原创 2017-07-12 19:14:58 · 338 阅读 · 0 评论 -
图的深度及广度优先遍历
//graph.h #include #include #include"queue.h" #include using namespace std; const int maxValue = 99; const int size = 10; struct Sight{ string name; int id; string brief; };原创 2018-05-23 10:13:20 · 356 阅读 · 0 评论