我想知道如果兩個數組的前n個元素相等,下列布爾值是否返回true。換句話說,如果n是5,那麼兩個數組的前5個元素是相等的,並且該方法應該返回true。 @Override
public boolean equal(char[] s, char[] t, int n) {
//goes through each value in the s array
for (int i
我需要創建一個函數: returns true if all elements in a slice are equal (they will all be the same type)
returns false if any elements in a slice are different
我覺得這樣做是扭轉片,並比較切片和逆轉的唯一途徑片。 有沒有更好的方法來做到這一點,這很好的語法