Skip to content

Instantly share code, notes, and snippets.

@ohbarye
Created January 18, 2021 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohbarye/f783df2748ee8dbebace6d994323db45 to your computer and use it in GitHub Desktop.
Save ohbarye/f783df2748ee8dbebace6d994323db45 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func main() {
nums := []int{
1977,
1802,
1856,
1309,
2003,
1854,
1898,
1862,
1857,
542,
1616,
1599,
1628,
1511,
1848,
1623,
1959,
1693,
1444,
1211,
1551,
1399,
1855,
1538,
1869,
1664,
1719,
1241,
1875,
1733,
1547,
1813,
1531,
1773,
624,
1336,
1897,
1179,
1258,
1205,
1727,
1364,
1957,
540,
1970,
1273,
1621,
1964,
1723,
1699,
1847,
1249,
1254,
1644,
1449,
1794,
1797,
1713,
1534,
1202,
1951,
1598,
1926,
1865,
1294,
1893,
1641,
1325,
1432,
1960,
413,
1517,
1724,
1715,
1458,
1775,
1317,
1694,
1484,
1840,
1999,
1811,
1578,
1658,
1906,
1481,
1313,
1997,
1339,
1592,
1971,
1453,
1706,
1884,
1956,
1384,
1579,
1689,
1726,
1217,
1796,
1536,
1213,
1867,
1304,
2010,
1503,
1665,
1361,
814,
2007,
1430,
1625,
1958,
860,
1799,
1942,
1876,
1772,
1198,
1221,
1814,
1826,
1667,
1334,
1504,
1420,
1164,
1414,
1934,
1823,
1507,
1195,
21,
1752,
1472,
1196,
1558,
1322,
1927,
1556,
1922,
277,
1828,
1883,
1280,
1947,
1231,
1915,
1235,
1961,
1494,
1324,
2009,
1367,
1545,
1736,
1575,
1214,
1704,
1833,
1663,
1474,
1894,
1754,
1564,
1321,
1119,
1975,
1987,
1873,
1834,
1686,
1574,
1505,
1656,
1688,
1896,
1982,
1554,
1990,
1902,
1859,
1293,
1739,
1282,
1889,
1981,
1283,
1687,
1220,
1443,
1409,
1252,
1506,
1742,
1319,
1882,
951,
1849,
}
m := make(map[int]int, len(nums))
for _, num := range nums {
if val, ok := m[num]; ok {
fmt.Println(num * val)
break
}
m[2020-num] = num
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment