mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-07 15:45:40 +08:00
更新 哈希表额外题目 排版格式修复
This commit is contained in:
@ -29,7 +29,7 @@
|
||||
|
||||
提示:可以假设 s 和 t 长度相同。
|
||||
|
||||
# 思路
|
||||
## 思路
|
||||
|
||||
字符串没有说都是小写字母之类的,所以用数组不合适了,用map来做映射。
|
||||
|
||||
@ -61,9 +61,9 @@ public:
|
||||
```
|
||||
|
||||
|
||||
# 其他语言版本
|
||||
## 其他语言版本
|
||||
|
||||
## Java
|
||||
### Java
|
||||
|
||||
```java
|
||||
class Solution {
|
||||
@ -87,7 +87,7 @@ class Solution {
|
||||
}
|
||||
```
|
||||
|
||||
## Python
|
||||
### Python
|
||||
|
||||
```python
|
||||
class Solution:
|
||||
@ -110,7 +110,7 @@ class Solution:
|
||||
return True
|
||||
```
|
||||
|
||||
## Go
|
||||
### Go
|
||||
|
||||
```go
|
||||
func isIsomorphic(s string, t string) bool {
|
||||
@ -132,7 +132,7 @@ func isIsomorphic(s string, t string) bool {
|
||||
}
|
||||
```
|
||||
|
||||
## JavaScript
|
||||
### JavaScript
|
||||
|
||||
```js
|
||||
var isIsomorphic = function(s, t) {
|
||||
@ -156,7 +156,7 @@ var isIsomorphic = function(s, t) {
|
||||
};
|
||||
```
|
||||
|
||||
## TypeScript
|
||||
### TypeScript
|
||||
|
||||
```typescript
|
||||
function isIsomorphic(s: string, t: string): boolean {
|
||||
@ -183,3 +183,4 @@ function isIsomorphic(s: string, t: string): boolean {
|
||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
||||
</a>
|
||||
|
||||
|
@ -432,3 +432,4 @@ function reverseList(head: ListNode | null): ListNode | null {
|
||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
||||
</a>
|
||||
|
||||
|
@ -30,7 +30,7 @@ words[i] 由小写英文字母组成
|
||||
|
||||
|
||||
|
||||
# 思路
|
||||
## 思路
|
||||
|
||||
这道题意一起就有点绕,不是那么容易懂,其实就是26个小写字符中有字符 在所有字符串里都出现的话,就输出,重复的也算。
|
||||
|
||||
@ -140,7 +140,7 @@ public:
|
||||
|
||||
## 其他语言版本
|
||||
|
||||
Java:
|
||||
### Java:
|
||||
|
||||
```Java
|
||||
class Solution {
|
||||
@ -174,7 +174,8 @@ class Solution {
|
||||
}
|
||||
}
|
||||
```
|
||||
Python
|
||||
### Python
|
||||
|
||||
```python
|
||||
class Solution:
|
||||
def commonChars(self, words: List[str]) -> List[str]:
|
||||
@ -218,7 +219,8 @@ class Solution:
|
||||
return l
|
||||
```
|
||||
|
||||
javaScript
|
||||
### JavaScript
|
||||
|
||||
```js
|
||||
var commonChars = function (words) {
|
||||
let res = []
|
||||
@ -285,7 +287,8 @@ var commonChars = function(words) {
|
||||
}
|
||||
```
|
||||
|
||||
TypeScript
|
||||
### TypeScript
|
||||
|
||||
```ts
|
||||
console.time("test")
|
||||
let str: string = ""
|
||||
@ -321,7 +324,8 @@ TypeScript
|
||||
return str.split("")
|
||||
```
|
||||
|
||||
GO
|
||||
### GO
|
||||
|
||||
```golang
|
||||
func commonChars(words []string) []string {
|
||||
length:=len(words)
|
||||
@ -357,7 +361,8 @@ func min(a,b int)int{
|
||||
}
|
||||
```
|
||||
|
||||
Swift:
|
||||
### Swift:
|
||||
|
||||
```swift
|
||||
func commonChars(_ words: [String]) -> [String] {
|
||||
var res = [String]()
|
||||
@ -397,7 +402,8 @@ func commonChars(_ words: [String]) -> [String] {
|
||||
}
|
||||
```
|
||||
|
||||
C:
|
||||
### C:
|
||||
|
||||
```c
|
||||
//若两个哈希表定义为char数组(每个单词的最大长度不会超过100,因此可以用char表示),可以提高时间和空间效率
|
||||
void updateHashTable(int* hashTableOne, int* hashTableTwo) {
|
||||
@ -449,7 +455,8 @@ char ** commonChars(char ** words, int wordsSize, int* returnSize){
|
||||
return ret;
|
||||
}
|
||||
```
|
||||
Scala:
|
||||
### Scala:
|
||||
|
||||
```scala
|
||||
object Solution {
|
||||
def commonChars(words: Array[String]): List[String] = {
|
||||
@ -483,7 +490,7 @@ object Solution {
|
||||
}
|
||||
```
|
||||
|
||||
Rust:
|
||||
### Rust:
|
||||
|
||||
```rust
|
||||
impl Solution {
|
||||
@ -522,3 +529,4 @@ impl Solution {
|
||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
||||
</a>
|
||||
|
||||
|
Reference in New Issue
Block a user