由买买提看人间百态

topics

全部话题 - 话题: currentlen
(共0页)
n*******n
发帖数: 45
1
木有用DP....
public int lengthOfLongestSubstring(String s) {
if (s == null) {
return 0;
}
if (s.length() < 2) {
return s.length();
}
int maxLength = 0;
int totalLen = s.length();
int currentLen = 0;
int cStart = 0;
Map indexMap = new HashMap<>();
while((totalLen - cStart) > maxLength) {
for(int i = cStart; i < totalLen; i++) {
Character cur = s.char... 阅读全帖
O*******d
发帖数: 20343
2
来自主题: CS版 - 怎样遍历一个字母的组合
#include
#include
static char buffer[32];
void Combination(int currentLen, char *charSet, int n)
{
int i;
for(i = 0; i < n; ++i)
{
buffer[currentLen] = charSet[i];
buffer[currentLen + 1] = '\0';
printf("%s\n", buffer);
Combination(currentLen + 1, charSet + 1 + i, n - 1 - i);
}
}
void main()
{
char charSet[] = "abcdefg";
Combination(0, charSet, strlen(charSet));
}
O*******d
发帖数: 20343
3
来自主题: Programming版 - 怎样遍历一个字母的组合 (转载)
#include
#include
static char buffer[32];
void Combination(int currentLen, char *charSet, int n)
{
int i;
for(i = 0; i < n; ++i)
{
buffer[currentLen] = charSet[i];
buffer[currentLen + 1] = '\0';
printf("%s\n", buffer);
Combination(currentLen + 1, charSet + 1 + i, n - 1 - i);
}
}
void main()
{
char charSet[] = "abcdefg";
Combination(0, charSet, strlen(charSet));
}
(共0页)