π
Is Positive
Is Positiveμ
λ¬Έ κΈ°μ΄ λ¬Έλ² +5pts
Problem
Write a function that returns true if a number is positive, false otherwise.
Examples
Input:
isPositive(5)Output:
trueInput:
isPositive(-3)Output:
falseExplanation
μ΄ λ¬Έμ λ **λΉκ΅ μ°μ°μ**λ₯Ό μ¬μ©νμ¬ μ«μμ λΆνΈλ₯Ό νλ³νλ λ°©λ²μ νμ΅ν©λλ€. **λΉκ΅ μ°μ°μ (>)** `>` μ°μ°μλ μΌμͺ½ κ°μ΄ μ€λ₯Έμͺ½ κ°λ³΄λ€ ν¬λ©΄ true, μλλ©΄ falseλ₯Ό λ°νν©λλ€. **μμμ μ μ** μμλ 0λ³΄λ€ ν° μμ λλ€. λ°λΌμ `num > 0`μ΄ μμλ₯Ό νλ³νλ 쑰건μ λλ€. **0μ μμκ° μλλλ€** μνμ μΌλ‘ 0μ μμλ μμλ μλλλ€. λ°λΌμ `isPositive(0)`μ falseλ₯Ό λ°νν΄μΌ ν©λλ€. **λΉκ΅ μ°μ°μμ κ²°κ³Όλ λΆλ¦¬μΈ** `num > 0`μ κ²°κ³Ό μμ²΄κ° true λλ fal...
View detailed explanation βKey Concepts
λΉκ΅ μ°μ°μ (>) λΆλ¦¬μΈ λ°ν μμ/μμ/0 κ΅¬λΆ μ‘°κ±΄μμ μ§μ λ°ν
Time: O(1) Space: O(1)
solution.js
Ctrl + Enter
Run tests to see results here.