Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active March 6, 2025 17:21
Show Gist options
  • Save lbvf50mobile/8460623173249481a6760533f68b9b25 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/8460623173249481a6760533f68b9b25 to your computer and use it in GitHub Desktop.
Leetcode: 2965. Find Missing and Repeated Values
// Leetcode: 2965. Find Missing and Repeated Values
// https://leetcode.com/problems/find-missing-and-repeated-values/description/
// = = = = = = = = = = = = = =
// Accepted.
// Thanks God, Jesus Christ!
// = = = = = = = = = = = = = =
// Runtime: 1 ms Beats 82.81%
// Memory: 7.07 MB Beats 90.63%
// 2025.03.06 Daily Challenge.
package main
import (
// "fmt"
)
func findMissingAndRepeatedValues(grid [][]int) []int {
freq := make([]int, 2501) // Just because of the problem limitations.
ans := []int{0, 9}
ii, jj := len(grid), len(grid[0])
last := ii * jj
for i := 0; i < ii; i += 1 {
for j := 0; j < jj; j += 1 {
freq[grid[i][j]] += 1
}
}
for i := 1; i <= last; i += 1 {
v := freq[i]
if 0 == v {
ans[1] = i
}
if 2 == v {
ans[0] = i
}
}
return ans
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment