611. Valid Triangle Number

611. Valid Triangle Number

class Solution {
    public int triangleNumber(int[] nums) {
		int count = 0;
		for (int i = 0; i < nums.length; i++) {
			for (int j = i+1; j < nums.length; j++) {
				for (int k = j+1; k  nums[k] &&
						nums[i] + nums[k] > nums[j]&&  
						nums[j] + nums[k] > nums[i]) {
						count++;
					}
				}
			}
		}
		return count;
	}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s