Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd1a1547

Browse files
add 1570
1 parentd83c7e0 commitd1a1547

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ _If you like this project, please leave me a star._ ★
3636
|1576|[Replace All ?'s to Avoid Consecutive Repeating Characters](https://leetcode.com/problems/replace-all-s-to-avoid-consecutive-repeating-characters/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1576.java)|[:tv:](https://youtu.be/SJBDLYqrIsM)|Easy|String|
3737
|1574|[Shortest Subarray to be Removed to Make Array Sorted](https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1574.java)||Medium|Array, Binary Search|
3838
|1572|[Matrix Diagonal Sum](https://leetcode.com/problems/matrix-diagonal-sum/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1572.java)||Easy|Array|
39+
|1570|[Dot Product of Two Sparse Vectors](https://leetcode.com/problems/dot-product-of-two-sparse-vectors/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1570.java)||Easy|Array, HashTable, Two Pointers|
3940
|1567|[Maximum Length of Subarray With Positive Product](https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1567.java)|[:tv:](https://youtu.be/bFer5PdsgpY)|Medium|Greedy|
4041
|1566|[Detect Pattern of Length M Repeated K or More Times](https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1566.java)|[:tv:](https://youtu.be/aJAV_VgmjdE)|Easy|Array|
4142
|1561|[Maximum Number of Coins You Can Get](https://leetcode.com/problems/maximum-number-of-coins-you-can-get/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1561.java)|[:tv:](https://youtu.be/hPe9Z3TiUrA)|Medium|Sort|
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
packagecom.fishercoder.solutions;
2+
3+
publicclass_1570 {
4+
publicstaticclassSolution1 {
5+
classSparseVector {
6+
int[]vector;
7+
8+
SparseVector(int[]nums) {
9+
this.vector =nums;
10+
}
11+
12+
// Return the dotProduct of two sparse vectors
13+
publicintdotProduct(SparseVectorvec) {
14+
int[]incoming =vec.vector;
15+
intdotProduct =0;
16+
for (inti =0;i <vector.length;i++) {
17+
dotProduct +=incoming[i] *this.vector[i];
18+
}
19+
returndotProduct;
20+
}
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp