我試圖實施amazon面試問題。 Find the maximum sum of lengths of non-overlapping contiguous subarrays with k as the maximum element.
Ex: Array: {2,1,4,9,2,3,8,3,4} and k = 4
Ans: 5
{2,1,4} => Length = 3
{3,4}
當我在一個簡單的控制檯應用程序中測試後增量操作符時,我意識到我不理解完整的概念。這對我來說很奇怪: int i = 0;
bool b = i++ == i;
Console.WriteLine(b);
輸出一直是錯誤的。我曾預料這將是事實。 AFAIK,在第2行,由於增量後,編譯器做了比較,並在我增加1後將b賦值爲真。但顯然我錯了。 之後,我修改了這樣的代碼: int i = 0;
b
任何人能向我解釋爲什麼n1的價值不是由1在這種情況下增加,或者換句話說,爲什麼數學運算沒有顯示1 package com.company;
public class Main {
public static void main(String[] args) {
System.out.println(isNumber(20, 21));
}
publ