Leetcode - Self Crossing
My code:
public class Solution {
public boolean isSelfCrossing(int[] x) {
if (x == null || x.length <= 3) {
return false;
}
for (int i = 3; i < x.length; i++) {
if (x[i] >= x[i - 2] && x[i - 3] >= x[i - 1]) {
return true;
}
if (i >= 4) {
if (x[i - 1] == x[i - 3] && x[i] + x[i - 4] >= x[i - 2]) {
return true;
}
}
if (i >= 5) {
if (x[i - 2] >= x[i - 4] && x[i] + x[i - 4] >= x[i - 2] && x[i - 1] + x[i - 5] >= x[i - 3] && x[i - 3] >= x[i - 1]) {
return true;
}
}
}
return false;
}
}
reference:
https://discuss.leetcode.com/topic/38014/java-oms-with-explanation
根據分析,一共可能出現這三種自旋。
然後根據三種情況,分別寫出判斷,就行了。
Anyway, Good luck, Richardo! -- 10/09/2016
相關文章
- Leetcode: Self CrossingLeetCodeROS
- LeetCode-Self CrossingLeetCodeROS
- 【LeetCode】Self Crossing(335)LeetCodeROS
- LeetCode:Product of Array Except SelfLeetCode
- Leetcode 238. Product of Array Except SelfLeetCode
- [LeetCode] 238. Product of Array Except SelfLeetCode
- &self 和 self 的區別
- rust語法super、self和SelfRust
- object-c [self class] 和 [self _cmd]Object
- new static ,new self ,self::, $this的一些理解
- Self-Attention GAN 中的 self-attention 機制
- POJ1700 Crossing River 過河問題ROS
- Tip之Self vs _
- 《SELF 自己》開發心路
- CSS align-selfCSS
- new self()與new static()
- Swift iOS : self sized cellSwiftiOSZed
- self.tableview.rekoaddataView
- Deep Crossing模型——經典的深度學習架構ROS模型深度學習架構
- block中self關鍵字的使用-防止self 被retain一次BloCAI
- 推薦系統實踐 0x10 Deep CrossingROS
- BZOJ4083 : [Wf2014]Wire CrossingROS
- iOS[super class]和[self class]iOS
- Python self用法詳解Python
- Kalman Filters( self-driving)Filter
- The importance of self-confidenceImportIDE
- Self-supervised Learning
- Python中return self的用法Python
- python---之cls,和selfPython
- 深入理解python之selfPython
- Transporting Tablespaces with Self-ContainedAI
- Scala的Infix Type與Self Types
- 檔案包含之/proc/self/environ
- 簡單易懂 —— this、self、static 的區別
- python變數中self的新增Python變數
- self::class和static::class的區別
- python---之物件導向selfPython物件
- Python Class self __init__筆記Python筆記