':type nums: List[int]
:rtype: int'

def triangleNumber(self, nums):

    result = 0
    nums.sort()
    for i in xrange((len(nums) - 2)):
        if (nums[i] == 0):
            continue
        k = (i + 2)
        for j in xrange((i + 1), (len(nums) - 1)):
            while ((k < len(nums)) and ((nums[i] + nums[j]) > nums[k])):
                k += 1
            result += ((k - j) - 1)
    return result
