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