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 #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 #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));
} |
|