LeetCode部分習題解答記錄 查詢

2021-10-24 14:38:16 字數 4261 閱讀 8482

class

solution

for(

int i =

0; i < nums2.length ; i++)}

return arrays.

copyofrange

(ans,

0, index);}

}

class

solution

for(

int i =

0; i < nums2.length;i++

)else}}

return arrays.

copyofrange

(ans,

0, index);}

}

class

solution

for(

int i =

0; i < s.

length()

;i ++

)for

(int i =

0; i < t.

length()

; i++)if

(count >0)

else}}

return

true;}

}

class

solution

int[

] ans =

newint[26

];//26個英文本母

//字串s出現字元加1,字串t出現字元減1

for(

int i =

0;i < s.

length()

; i++

)//若ans中有不為0的數,則說明s與t中的字元出現的次數至少有乙個不相等

for(

int i =

0;i < ans.length;i++)}

return

true;}

}

class

solution

return n ==1;

}public

intadd

(int n)

return sum;

}}

class

solution

hashmap

hm =

newhashmap

<

>()

;for

(int i =

0; i < str.length ; i ++)}

return

true;}

}

class

solution

else

if(map.

get(ch1)

!= ch2)

return

false;}

return

true;}

}

class

solution

}return

true;}

}

class

solution

//用list來儲存map集合

list

> list =

newarraylist

>

(hm.

entryset()

);//list排序,重寫排序器,根據從大到小排序

list.

sort

(new

comparator

>()

});//輸出每個字元出現的次數,並新增到sb中,最終轉換為字串輸出

for(

int i =

0; i < list.

size()

; i++)}

return sb.

tostring()

;}}

class

solution

else

if(sum <0)

else}}

return list;

}}

class

solution

for(

int i =

0; i < nums.length;i++

) left++

; right--

;while

(left < right && nums[left]

== nums[left-1]

) left++

;while

(left < right && nums[right]

== nums[right+1]

) right--;}

else

if(sum < target)

else}}

}return list;

}}

class

solution

for(

int i =

0; i < nums.length -

3;i++

)//剪枝操作

if(nums[i]

+ nums[i +1]

+ nums[i +2]

+ nums[i +3]

> target)

if(nums[i]

+ nums[length -3]

+ nums[length -2]

+ nums[length -1]

< target)

for(

int j = i+

1; j < nums.length-

2; j++)if

(nums[i]

+ nums[j]

+ nums[length -2]

+ nums[length -1]

< target)

int left = j+1;

int right = nums.length -1;

while

(left < right)

else

if(sum < target)

else}}

}return list;

}}

class

solution

if(sum == target)

else

if(sum < target)

else}}

return best;

}}

class

solution

}for

(int i =

0; i < length ;i++)}

}return result;

}}

class

solution

//每次都壓入,將所有str分組

hm.get(s)

.add

(value);}

return

newarraylist

<

>

(hm.

values()

);}}

class

solution

for(map.entry

entry: hm.

entryset()

)}} hm.

clear()

;}return result;

}}

class

solution

hs.add(nums[i]);

if(hs.

size()

> k)

}return

false;}

}

class

solution

ts.add(

(long

)nums[i]);

if(ts.

size()

> k)

}return

false;}

}

1 7習題解答

根據自己的創作理念,結合市場調研得來的資料,參考開發人員的建議,在開發條件允許的基礎上,將遊戲創意以及遊戲內容和規則細化完整,形成策劃文件。同時,從設計遊戲大綱,發哦規劃所有細節重點,再到開發過程的全程協調與監控,都屬於工作範疇。1.喜歡玩遊戲,玩遊戲時有深度和廣度。自省 不是所有遊戲都喜歡,看型別...

SICP習題解答1 1 1 8

lang racket exercise 1.1 10 5 3 4 9 1 6 2 2 4 4 6 define a 3 define b a 1 a b a b a b if and b a b a b ba cond a 4 6 b 4 6 7 a else 25 2 if b a b a co...

SICP習題解答2 7 2 16

lang racket exercise 2.7 define make interval a b cons a b define upper bound interval max car interval cdr interval define lower bound interval min c...