can you give some explain about code of nocycles and nojoin ?
yin10
@yin10
Posts made by yin10

RE: Python O(n) BFS undirected SCC

[Python] DP solution
use dp[i] to mem the min cost to get step i, it get from either dp[i2] or dp[i1].
def minCostClimbingStairs(self, cost): if len(cost) == 2: return min(cost[0],cost[1]) dp = [cost[0]] dp.append(cost[1]) length = len(cost) for i in xrange(2,length): dp.append(min(dp[i2],dp[i1])+cost[i]) return min(dp[1],dp[2])

Python, two pointer solution
Python, two pointer solution, first get the sorted list, then use two pointer to check. '''''' def findTarget(self, root, k): """ :type root: TreeNode :type k: int :rtype: bool """ sortList = self.inorder(root,[]) lo,hi = 0,len(sortList)1 while lo < hi: if sortList[lo] + sortList[hi] == k: return True elif sortList[lo] + sortList[hi] < k: lo += 1 else: hi = 1 return False def inorder(self,node,lt): if node is None: return lt self.inorder(node.left,lt) lt.append(node.val) self.inorder(node.right,lt) return lt

RE: Python Solution with O(n)
@sylvanyang it use the stack, in normal average, it is O(1) for st, so it is O(n)

Python Solution O(n) initial and O(1) sumRange
the code as following, no need for save the nums as well.
"""def __init__(self, nums): """ :type nums: List[int] """ sum = 0 self.sumList = [0] for i in range(len(nums)): sum += nums[i] self.sumList.append(sum) def sumRange(self, i, j): """ :type i: int :type j: int :rtype: int """ return self.sumList[j+1]  self.sumList[i]

RE: Java Solution, Min and Max
@FannyChung it could be negative.

RE: Simple Java O(n) solution
the following is my understanding for your code, if wrong, pls correct me:
P[i] = PorL[i  1]; //this line means ending with P, just appending P in PorL
PorL[i] = (P[i] + P[i  1] + P[i  2]) % M; //P[i] end with P, P[i1], end with one L(or PL), P[i2], end with two L(or LL).and last logic ,res init value with PorL without A, and add one A to the sequence.
long res = PorL[n];
for (int i = 0; i < n; i++) { // inserting A into (n1)length strings
long s = (PorL[i] * PorL[n  i  1]) % M;
res = (res + s) % M;
}
very nice and clean solution. 
RE: Testcase "11"
@rashmi.twr1990 pls check the question again: find the closest integer (not including itself)

RE: Simple Java solution O(n^2)
@vinod23 thanks for your clear reply.

RE: Neat DFS java solution
@vinod23 said in Neat DFS java solution:
It is good solution.
BTW, visited use boolean[] better.