Simple Scala Solution


  • 0
    L
    object Solution {
      def isPerfectSquare( num:Int):Boolean ={
        var numTemp =num
        val mid:Int = numTemp/2
        if(numTemp ==1)
          return true
        else {
          for (i <- 2 to mid) {
            var result:Double =numTemp
            if(result/i == i) 
                return true
          }
          return false
        }
      }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.