Sort by

recency

|

16 Discussions

|

  • + 0 comments

    Efficient algorithms like RMQ are crucial in optimizing workflows, much like tools for video enhancement such as https://winkapkgeek.com/.

  • + 0 comments

    Could you please add Python as a possible programming language?

  • + 0 comments

    Could you please add Python as a possible programming language?

  • + 0 comments

    Hi, I have got a WA at case #4. But I check every output of my code with the answer, they are the same. Can someone know what happened?

    Here is my code

    object Solution {
    
     def dpSolver(A:Array[Int], query:Array[Array[Int]] ):Unit = {
        val dp = Array.fill(A.length, A.length)(Int.MaxValue)
        for{i <- A.indices} dp(i)(i) = A(i)
        for{
          i <- A.indices
          j <- i + 1 until A.length
        }
          dp(i)(j) =  A(j) min dp(i)(j-1)
        query foreach {case Array(i,j) => println(dp(i)(j))}
      }
    
      def readArray():Array[Int] = readLine.split(' ').map(_.toInt)
      def main(args: Array[String]) {
        readArray match {
          case Array(n, m) => dpSolver( readArray, Array.fill(m)(readArray))
        }
      }
    }
    
  • [deleted]
    + 0 comments

    Maybe this'll be helpful for those using haskell who have issues with time limits and reading input. This is my go to for reading a bunch of ints:

    import qualified Data.ByteString.Char8 as B
    import Data.List (unfoldr)
    import Data.Char (isSpace)
    
    ints = unfoldr (B.readInt . B.dropWhile isSpace) 
    
    solve (n:xs) = error "some solution to a hackerrank problem"
    main = solve =<< ints <$> B.getContents