{"id":4604,"date":"2022-02-26T22:30:19","date_gmt":"2022-02-26T14:30:19","guid":{"rendered":"https:\/\/1989lifejourney.com\/?p=4604"},"modified":"2022-02-26T22:30:19","modified_gmt":"2022-02-26T14:30:19","slug":"print-all-permutation-of-an-array","status":"publish","type":"post","link":"https:\/\/1989lifejourney.com\/?p=4604","title":{"rendered":"Print all permutation of an array"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u984c\u76ee:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7d66\u5b9a\u4e00\u7d44\u6574\u6578array\uff0c\u5370\u51fa\u6240\u6709\u7684\u6392\u5217\u7d44\u5408<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">EX: input: [1,2], output: [1,2], [2,1]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">       input: [1,2,3], output: [1,2,3],[1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>func helper(_ arr: inout &#091;Int], _ index: Int) {\n    for i in index ..&lt; arr.count {\n        arr.swapAt(index, i)\n        helper(&amp;arr, index + 1)\n        arr.swapAt(index, i)\n    }\n    if index == arr.count {\n        print(arr)\n    }\n}\n\nvar arr = &#091;1,2,3,4]\nhelper(&amp;arr,0)\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u984c\u76ee: \u7d66\u5b9a\u4e00\u7d44\u6574\u6578array\uff0c\u5370\u51fa\u6240\u6709\u7684\u6392\u5217\u7d44\u5408 EX: input: [1,2], output: [1, [&hellip;]<\/p>\n","protected":false},"author":139426785,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","_postgate_lock_override":"inherit","_postgate_lock_mode":"inherit","_postgate_preview_mode":"inherit","_postgate_preview_limit":0,"_postgate_product_ids":[],"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_seo_schema_type":"","jetpack_seo_llms_txt_always_include":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_wpcom_ai_launchpad_first_post":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"{title}\n\n{excerpt}\n\n{url}","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wpas_customize_per_network":false,"jetpack_post_was_ever_published":false},"categories":[89600350,1],"tags":[],"post_folder":[],"class_list":["post-4604","post","type-post","status-publish","format-standard","hentry","category-leetcode","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paR5vw-1cg","jetpack-related-posts":[{"id":4067,"url":"https:\/\/1989lifejourney.com\/?p=4067","url_meta":{"origin":4604,"position":0},"title":"Quick Sort","author":"Kevin","date":"15 1 \u6708, 2022","format":false,"excerpt":"func partition(arr: inout [Int], front: Int, \u2026","rel":"","context":"\u5728\u300cIOS Development\u300d\u4e2d","block_context":{"text":"IOS Development","link":"https:\/\/1989lifejourney.com\/?cat=37324612"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4071,"url":"https:\/\/1989lifejourney.com\/?p=4071","url_meta":{"origin":4604,"position":1},"title":"Merge sort","author":"Kevin","date":"15 1 \u6708, 2022","format":false,"excerpt":"func merge(arr: inout [Int], front: Int, end:\u2026","rel":"","context":"\u5728\u300cIOS Development\u300d\u4e2d","block_context":{"text":"IOS Development","link":"https:\/\/1989lifejourney.com\/?cat=37324612"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4982,"url":"https:\/\/1989lifejourney.com\/?p=4982","url_meta":{"origin":4604,"position":2},"title":"Difference between value type and a reference type in iOS swift\ufffc","author":"Kevin","date":"29 3 \u6708, 2022","format":false,"excerpt":"\u4ee5\u4e0b\u8cc7\u6599\u7686\u53c3\u8003\u81eaRef1\uff0c\u9019\u88e1\u50c5\u4f5c\u500b\u4eba\u5b78\u7fd2\u6574\u7406: Definition of Value type \u2026","rel":"","context":"\u5728\u300cIOS Development\u300d\u4e2d","block_context":{"text":"IOS Development","link":"https:\/\/1989lifejourney.com\/?cat=37324612"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4857,"url":"https:\/\/1989lifejourney.com\/?p=4857","url_meta":{"origin":4604,"position":3},"title":"Array Permutation\/Combination by Iterative","author":"Kevin","date":"21 3 \u6708, 2022","format":false,"excerpt":"\u53c3\u8003\u5be6\u4f5c: https:\/\/www.youtube.com\/watch?v=zIY2BWdsbFs \u2026","rel":"","context":"\u5728\u300cLeetCode\u300d\u4e2d","block_context":{"text":"LeetCode","link":"https:\/\/1989lifejourney.com\/?cat=89600350"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4074,"url":"https:\/\/1989lifejourney.com\/?p=4074","url_meta":{"origin":4604,"position":4},"title":"KMP algorithm","author":"Kevin","date":"16 1 \u6708, 2022","format":false,"excerpt":"\u5b57\u4e32\u6bd4\u5c0d\u554f\u984c: \u7d66\u5b9a\u4e00\u500b\u5b57\u4e32(txt)\u548c\u53e6\u4e00\u500b\u5b57\u4e32(pattern)\uff0c\u78ba\u8a8dpattern\u5b57\u4e32\u662f\u5426\u5b58\u5728\u2026","rel":"","context":"\u5728\u300cIOS Development\u300d\u4e2d","block_context":{"text":"IOS Development","link":"https:\/\/1989lifejourney.com\/?cat=37324612"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/img.youtube.com\/vi\/V5-7GzOfADQ\/0.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":4134,"url":"https:\/\/1989lifejourney.com\/?p=4134","url_meta":{"origin":4604,"position":5},"title":"System Design Practice &#8211; 1","author":"Kevin","date":"30 1 \u6708, 2022","format":false,"excerpt":"\u984c\u76ee: \u67093\u7a2eRoutine:(1)\u6bcf\u500bRoutine\u6709\u76f8\u540c\u7684\u5c6c\u6027\uff0c\u4f46\u4e5f\u6709\u5404\u5225\u4e0d\u540c\u7684\u5c6c\u6027(2)\u6bcf\u500bR\u2026","rel":"","context":"\u5728\u300cIOS Development\u300d\u4e2d","block_context":{"text":"IOS Development","link":"https:\/\/1989lifejourney.com\/?cat=37324612"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=\/wp\/v2\/posts\/4604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=\/wp\/v2\/users\/139426785"}],"replies":[{"embeddable":true,"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4604"}],"version-history":[{"count":3,"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=\/wp\/v2\/posts\/4604\/revisions"}],"predecessor-version":[{"id":4607,"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=\/wp\/v2\/posts\/4604\/revisions\/4607"}],"wp:attachment":[{"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4604"},{"taxonomy":"post_folder","embeddable":true,"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=%2Fwp%2Fv2%2Fpost_folder&post=4604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}