{ "cells": [ { "cell_type": "markdown", "source": [ "Given an array of integers where 1 ≤ a[i] ≤ _n_ ( _n_ = size of array), some\n", "elements appear twice and others appear once.\n", "\n", "Find all the elements of [1, _n_ ] inclusive that do not appear in this array.\n", "\n", "Could you do it without extra space and in O( _n_ ) runtime? You may assume\n", "the returned list does not count as extra space.\n", "\n", "**Example:**\n", "\n", "\n", "\n", " Input:\n", " [4,3,2,7,8,2,3,1]\n", "\n", " Output:\n", " [5,6]" ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "find_all_numbers_disappeared_in_an_array (generic function with 1 method)" }, "metadata": {}, "execution_count": 1 } ], "cell_type": "code", "source": [ "# @lc code=start\n", "using LeetCode\n", "\n", "function find_all_numbers_disappeared_in_an_array(arr::Vector{Int})\n", " return setdiff(eachindex(arr), arr)\n", "end\n", "\n", "# add your code here:\n", "# @lc code=end" ], "metadata": {}, "execution_count": 1 }, { "cell_type": "markdown", "source": [ "---\n", "\n", "*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" ], "metadata": {} } ], "nbformat_minor": 3, "metadata": { "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.10.1" }, "kernelspec": { "name": "julia-1.10", "display_name": "Julia 1.10.1", "language": "julia" } }, "nbformat": 4 }