題⽬描述
求 1+2+3+...+n ,要求不能使⽤乘除法、 for 、 while 、 if 、 else 、 switch 、 case 等關鍵字及條件判斷語句( A?B:C )。
示例
輸⼊:5
輸出:15
思路及解答
用for循環
這個問題,如果直接使⽤ for 循環,超級簡單,重拳出擊,時間複雜度為 O(n) 。代碼如下:
public class Solution {
題目
Two players play a turn based game on a binary tree. We are giventherootof this binary tree, and the number of nodesnin the tree.nis odd, andeach node has a distinct value from1ton.
Postman的優點Postman的配置
Postman被500萬開發者和超過10萬家公司使用,每個月可以訪問1.3億個api。
The only complete API development environment:唯一完整的API開發環境。
Integrated tools for every stage of the A