title: Continuous Subarray Sum in Kotlin
body: <p>I am trying to learn Kotlin these days and thought of converting my Java leetcode solutions into kotlin to understand the syntax and practice its nuances. I am still facing issues with Collections. Below is the code for one of the famous interview problem Continuous Subarray Sum.
  Details about use cases: <a href="https://leetcode.com/problems/continuous-subarray-sum/" rel="nofollow noreferrer">https://leetcode.com/problems/continuous-subarray-sum/</a></p>
  <pre><code>class Solution {
      fun checkSubarraySum(nums: IntArray, k: Int): Boolean {
          
          var map = mutableMapOf&lt;Int,Int&gt;()
          var sum = 0
          map.put(0,-1)
          for (i in 0 until nums.size-1){
              sum += nums[i]
              
              if (k != 0){
                  sum = sum % k
              }
              
              if (map.containsKey(sum)){
                  if (i - map.get(sum) &gt; 1){
                      return true
                  }
              }
              else{
                  map.put(sum,i)
              }
          }
          
          return false
      }
  }
  </code></pre>
  <p>I am getting this error.</p>
  <pre><code>Line 15: Char 25: error: type mismatch: inferred type is Int? but Int was expected
                  if (i - map.get(sum) &gt; 1){
           
  </code></pre>
  <p>What am I doing wrong here?
  Please note that I am really new to this language so this question might be dumb.               ^</p>