Multiples of 3 and 5

Multiples of 3 and 5

Answer is 233168 pragmatically.

I did not use the Math to get the answer.

public class Main {
public static int multiple3and5below1000() { 
int sum = 0; 
for (int i = 3; i < 1000; i++) { 
if ((i >= 3 && ((i % 3) == 0) || (i >= 5 && ((i % 5) == 0)))) 
sum += i; } 
return sum; }
 public static void main(String[] args) { 
 System.out.println(multiple3and5below1000()); }
}

690. Employee Importance

690. Employee Importance

/*
// Employee info
class Employee {
    // It's the unique id of each node;
    // unique id of this employee
    public int id;
    // the importance value of this employee
    public int importance;
    // the id of direct subordinates
    public List subordinates;
};
*/
class Solution {
	public Employee getEmployeeById(List employees, int id1) {
		for (int i = 0; i < employees.size(); i++) {
			if (employees.get(i).id == id1)
				return employees.get(i);
		}
		return null;
	}

	public int getImportance(List employees, int id) {
		int result = 0;
		Employee current = getEmployeeById(employees, id);
		result += current.importance;

		if (current.subordinates == null || current.subordinates.size() == 0)
			return result;

		for (int i = 0; i < current.subordinates.size(); i++)
			result += getImportance(employees, current.subordinates.get(i));

		return result;

	}
}

520. Detect Capital

520. Detect Capital

class Solution {
    	public boolean detectCapitalUse(String word) {
		if (Character.isLowerCase(word.charAt(0))) {
			if (isAllLowerCase(word.substring(1)))
				return true;
		} else {
			if (isAllLowerCase(word.substring(1)) || isAllUpperCase(word.substring(1)))
				return true;
		}
		return false;
	}

	public boolean isAllLowerCase(String word) {
		for (int i = 0; i < word.length(); i++) {
			if (Character.isUpperCase(word.charAt(i)))
				return false;
		}
		return true;
	}

	public boolean isAllUpperCase(String word) {
		for (int i = 0; i < word.length(); i++) {
			if (!Character.isUpperCase(word.charAt(i)))
				return false;
		}
		return true;
	}
}