We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 89425c3 commit c60e6f2Copy full SHA for c60e6f2
2019.02.01-leetcode413/sourcema.md
@@ -0,0 +1,26 @@
1
+# leetcode 413
2
+ class Solution {
3
+ public int numberOfArithmeticSlices(int[] A) {
4
+ if(A==null||A.length==0){
5
+ return 0;
6
+ }
7
+ int res=0;
8
+ for(int i=0;i<A.length;i++){
9
+ for(int j=i+1;j<A.length;j++){
10
+ if(j-i>=2&&isArithmetic(A,i,j)){
11
+ res+=1;
12
13
14
15
+ return res;
16
17
+ public boolean isArithmetic(int[] arr,int i,int j){
18
+ int d=arr[i+1]-arr[i];
19
+ for(int k=i+1;k<j;k++){
20
+ if(arr[k+1]-arr[k]!=d){
21
+ return false;
22
23
24
+ return true;
25
26
+}
0 commit comments