Sort by

recency

|

126 Discussions

|

  • + 0 comments

    Here is my c++ solution, you can watch video explanation here : https://youtu.be/Qs9rxqfzTs8

    bool is_smart_number(int num) {
        int val = (int) sqrt(num);
        if(val * val == num)
            return true;
        return false;
    }
    
  • + 0 comments

    For Java coders: change line 10 to:

            if(val * val == num)
    

    A smart number is only smart if its a perfect square.

  • + 0 comments

    bool is_smart_number(int num) { if(num<=0) return false;

    int val = (int) sqrt(num);
    if(val * val == num)
        return true;
    return false;
    

    }

    Its correct but compiling false

  • + 0 comments

    Why this problem doesnt support JavaScript language

    function isSmartNumber(num) {
        var val = Math.floor(Math.sqrt(num));
        if (val * val === num) {
            return true;
        }
        return false;
    }
    
  • + 0 comments

    import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;

    public class Solution { public static boolean isSmartNumber(int num) { int val = (int) Math.sqrt(num);
    if(num / val == 1) return true; return false; }

    public static void main(String[] args) {
        int test_cases;
        Scanner in = new Scanner(System.in);
        test_cases = in.nextInt();
        int num;
        for(int i = 0; i < test_cases; i++){
            num = in.nextInt();
            boolean ans = isSmartNumber(num);
            if(ans){
                System.out.println("YES");
            }
            else System.out.println("NO");
        }
    }
    

    }