Skip to content

Missing Test Case for Byte Overflow - 1207. Unique Number of Occurrences #19472

@naXa777

Description

@naXa777

LeetCode Username

naXa777

Problem number, title, and link

1207. Unique Number of Occurrences

Category of the bug

  • Problem description
  • Solved examples
  • Problem constraints
  • Problem hints
  • Incorrect or missing "Related Topics"
  • Incorrect test Case (Output of test case is incorrect as per the problem statement)
  • Missing test Case (Incorrect/Inefficient Code getting accepted because of missing test cases)
  • Editorial
  • Programming language support

Description of the bug

Incorrect Code getting accepted. The code AC submission link is https://leetcode.com/problems/unique-number-of-occurrences/submissions/1148757302/

In my code I use UByteArray. UByte values are in range 0..255. If test input contains a number repeated 256 or more times, byte overflow happens. That's why my code is incorrect.

Language used for code

Kotlin

Code used for Submit/Run operation

class Solution {
    fun uniqueOccurrences(arr: IntArray): Boolean {
        val frequencies = UByteArray(2000)
        for (n in arr) {
            ++frequencies[n + 1000]
        }
        val uniq = BooleanArray(2000)
        for (i in 0 until 2000) {
            val freq = frequencies[i].toInt()
            if (freq == 0) continue
            if (uniq[freq]) return false
            uniq[freq] = true
        }
        return true
    }
}

Expected behavior

Incorrect Code is rejected by test.

Screenshots

image

Additional context

Please add a test with this input:
[1,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions