From 53a1542ffc4d8d5c9e1db82d3d94be3ef9e2f7e8 Mon Sep 17 00:00:00 2001 From: Xiaohui Wang Date: Wed, 13 Apr 2016 16:47:28 -0400 Subject: [PATCH 1/2] Partition (Dynamic Programming) added --- dynamic_programming/main | Bin 0 -> 9824 bytes dynamic_programming/partition.cc | 52 +++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 dynamic_programming/main create mode 100644 dynamic_programming/partition.cc diff --git a/dynamic_programming/main b/dynamic_programming/main new file mode 100755 index 0000000000000000000000000000000000000000..87c481dac9b613cb57efdd691252593677a7b52e GIT binary patch literal 9824 zcmeHNZ)_CD6`wOEF<@ArpeFr?MW78u1sg(YWYV4+k1`e?6?Rh3$=s`cnn545@Qm}1B0%>h6z!prHMQA)Kt9L;%O7@ya{YjW&K zF3R5myjb{0!En0_hL3b(&K+OE!E1Nck$k`Ss7`8e0i|rHZ>cYEhI%NflU%(N)Cp>s zQ6rMFqdULLd*fAE*64tfTT3dsp38}GNXl?XMvry1b%$h+9$64yl@nhsERx-LxYY9` zWhihzylMxp$yq^iAs*cqP|Z{RKHb;2e=l!nY;mTlTzP{`)an#0;aGXKw2W=U?O#oN z6=S${SOvyjj5+GBVr&o#Dqu+G0$t0;&{`p{Cw>$3P_6)&JsdpUq_?s*o6GixW$nvpCu|~pp=3CZwCCr_?L*^ZWZRz$8q)vlL>?05k_Cy zh~1dvDe^YSXJ|0_OdY?W3~c}}R6Zk2U)o%Ee2G70_*0mSk9iC}lleDX%Pp`VyaGnRPHQdCC|c&us7{uiP>Num0tgz3Ks@XKQSpJl>~jR?>CljSF1$}&$_3#J}u0XfQi;^3OTsd&aC z)GGia@T+3{I>7q?e$A|W)pqTla?Kc(ubRGO19ng!PkS2GF@%<`tNe*_DgoRP;Q0_S zmMsL0?-^!;{DLy@U07njg#o0umcJp?X}|(isI!QJVww}iC^O-#f~{O1M4A-=Pr4gmL@u zd+EQUev}Ojj9K-2{Pq|uM(J;<80t#_#0L8tjWU zi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Aiu@wykj^WL&*!|p@GOD0_!L>>{D5kaa~<0Jp>CZV NMH>5 + +using namespace std; + +bool partition(int arr[], int n){ + int sum = 0; + for (int i=0; i= arr[i-1]){ + matrix[i][j] = matrix[i][j] || matrix[i-1][j-arr[i-1]]; + } + } + } + } + return matrix[n][sum]; +} +int main(){ + int arr1[] = {3,1,1,2,2,1}; + int arr2[] = {4,2,1,3,4}; + int arr3[] = {2,4,5,5}; + cout< Date: Wed, 13 Apr 2016 16:47:46 -0400 Subject: [PATCH 2/2] Partition (Dynamic Programming) added --- dynamic_programming/main | Bin 9824 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100755 dynamic_programming/main diff --git a/dynamic_programming/main b/dynamic_programming/main deleted file mode 100755 index 87c481dac9b613cb57efdd691252593677a7b52e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9824 zcmeHNZ)_CD6`wOEF<@ArpeFr?MW78u1sg(YWYV4+k1`e?6?Rh3$=s`cnn545@Qm}1B0%>h6z!prHMQA)Kt9L;%O7@ya{YjW&K zF3R5myjb{0!En0_hL3b(&K+OE!E1Nck$k`Ss7`8e0i|rHZ>cYEhI%NflU%(N)Cp>s zQ6rMFqdULLd*fAE*64tfTT3dsp38}GNXl?XMvry1b%$h+9$64yl@nhsERx-LxYY9` zWhihzylMxp$yq^iAs*cqP|Z{RKHb;2e=l!nY;mTlTzP{`)an#0;aGXKw2W=U?O#oN z6=S${SOvyjj5+GBVr&o#Dqu+G0$t0;&{`p{Cw>$3P_6)&JsdpUq_?s*o6GixW$nvpCu|~pp=3CZwCCr_?L*^ZWZRz$8q)vlL>?05k_Cy zh~1dvDe^YSXJ|0_OdY?W3~c}}R6Zk2U)o%Ee2G70_*0mSk9iC}lleDX%Pp`VyaGnRPHQdCC|c&us7{uiP>Num0tgz3Ks@XKQSpJl>~jR?>CljSF1$}&$_3#J}u0XfQi;^3OTsd&aC z)GGia@T+3{I>7q?e$A|W)pqTla?Kc(ubRGO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