Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions problems/0005.最长回文子串.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,26 @@ public:

# 其他语言版本

## Java
Java:

```java
public int[] twoSum(int[] nums, int target) {
int[] res = new int[2];
if(nums == null || nums.length == 0){
return res;
}
Map<Integer, Integer> map = new HashMap<>();
for(int i = 0; i < nums.length; i++){
int temp = target - nums[i];
if(map.containsKey(temp)){
res[1] = i;
res[0] = map.get(temp);
}
map.put(nums[i], i);
}
return res;
}
```

```java
// 双指针 中心扩散法
Expand Down Expand Up @@ -291,7 +310,7 @@ class Solution {
}
```

## Python
Python

```python
class Solution:
Expand All @@ -312,7 +331,8 @@ class Solution:
return s[left:right + 1]

```
> 双指针法:
双指针:

```python
class Solution:
def longestPalindrome(self, s: str) -> str:
Expand Down Expand Up @@ -340,13 +360,13 @@ class Solution:
return s[start:end]

```
## Go
Go:

```go

```

## JavaScript
JavaScript

```js
//动态规划解法
Expand Down Expand Up @@ -462,8 +482,9 @@ var longestPalindrome = function(s) {
};
```

## C
动态规划:
C:

动态规划:
```c
//初始化dp数组,全部初始为false
bool **initDP(int strLen) {
Expand Down Expand Up @@ -513,7 +534,7 @@ char * longestPalindrome(char * s){
}
```

双指针:
双指针
```c
int left, maxLength;
void extend(char *str, int i, int j, int size) {
Expand Down