I love string,Java数据结构与算法pdf下载

Mr X has an operation sequence. This operation sequence can be written as a string. For each operation, the next character of the operation sequence can be inserted before or after the current string. For example, my operation sequence is “aabac”, suppose the sequence obtained after the first four operations is “baaa”, then after the last operation, the string may become “baaac” or “cbaaa”. It can be seen that there is only one operation method for the first operation. For other operations, there are only two methods of operation.

For each operation method, there will be a score. The smaller the lexicographic order of the final string, the higher the final score.

Then, for a given operation sequence, how many operation methods can get the maximum score.

The two operation methods are different. If and only if there is a certain operation (not the first operation), one operation will be inserted before the current string, and the other operation will be inserted after the current string.

Input

Enter a positive integer T (T≤10) on the first line to represent the number of test cases.

For each test case:

the first line contains a integer n (1≤n≤100000) to represent the length of the string.

the second line contains a string of lowercase letters , which represents the sequence of operations.

Output

For each test case, output a line of a positive integer to represent the number of schemes, and the answer is modulo 1000000007

Sample Input

1

5

abcde

Sample Output

1

题解

这题在写的时候就发现了,只要判断前面几个是否是一个字母

如果是就算出有多少个就行

然后用快速幂来乘

得出最后的结果

代码


#include<iostream>

#define ll long long 

using namespace std;

ll fastPower(ll base, ll power,ll mod) {//快速幂 

    ll result = 1;

    while (power > 0) {

        if (power & 1) {//此处等价于if(power%2==1)

            result = result * base % mod;

        }

        power >>= 1;//此处等价于power=power/2

        base = (base * base) % mod;

    }

    return result;

}


# **最后**

**最后,强调几点:**

*   1\. 一定要谨慎对待写在简历上的东西,一定要对简历上的东西非常熟悉。因为一般情况下,面试官都是会根据你的简历来问的; 能有一个上得了台面的项目也非常重要,这很可能是面试官会大量发问的地方,所以在面试之前好好回顾一下自己所做的项目;
*   2\. 和面试官聊基础知识比如设计模式的使用、多线程的使用等等,可以结合具体的项目场景或者是自己在平时是如何使用的;
*   3\. 注意自己开源的Github项目,面试官可能会挖你的Github项目提问;

我个人觉得面试也像是一场全新的征程,失败和胜利都是平常之事。所以,劝各位不要因为面试失败而灰心、丧失斗志。也不要因为面试通过而沾沾自喜,等待你的将是更美好的未来,继续加油!

> **以上面试专题的答小编案整理成面试文档了,文档里有答案详解,以及其他一些大厂面试题目。**

**如何获取整理好的Java面试专题资料?**

**[资料获取方式:点击这里免费下载](https://codechina.csdn.net/m0_60958482/java-p7)**

# **面试答案**

![三面头条+四面阿里+五面腾讯拿offer分享面经总结,最终入职阿里](https://img-blog.csdnimg.cn/img_convert/0a08d36818e71bf6f224cf4173d5ca3a.png)

![三面头条+四面阿里+五面腾讯拿offer分享面经总结,最终入职阿里](https://img-blog.csdnimg.cn/img_convert/7eee386343307a5b780f37fe69e26cc5.png)

://codechina.csdn.net/m0_60958482/java-p7)**

# **面试答案**

[外链图片转存中...(img-NQkPUrZD-1630206957085)]

[外链图片转存中...(img-gyjmxYru-1630206957087)]

![三面头条+四面阿里+五面腾讯拿offer分享面经总结,最终入职阿里](https://img-blog.csdnimg.cn/img_convert/daea65c4f90dbea36b7019d2eac36120.png)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值