This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Programare Dinamica | |
| ------------------- | |
| Este o tehnica care conduce , de cele mai multe ori, la un timp de calcul polinomial.Mai mult, | |
| furnizeaza intotdeauna solutia OPTIMA. Din nefericire, programarea dinamica nu se poate aplica tuturor problemelor , ci numai celor care indeplinesc anumite conditii. | |
| Se considera o problema in care rezultatul se obtine care urmare a unui sir de DECIZII | |
| D1, D2, D3, ..., Dn. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <vector> | |
| using namespace std; | |
| //4 5 6 | |
| //i | |
| //1 2 3 | |
| // j |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <vector> | |
| using namespace std; | |
| vector<int> interclasare(const vector<int> A, const vector<int> B) { | |
| vector<int> R; | |
| int i = 0, j = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <vector> | |
| using namespace std; | |
| //5 4 3 2 1 | |
| //prima iteratie: 4 3 2 1 5 | |
| //a doua: 1 2 3 4 5 | |
| //(a[0],a[1]) (a[1],a[2]),...(a[3],a[4]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - Permutari n = 3 | |
| n! = 3! = 6 | |
| 1 2 3 | |
| ..... | |
| 3 2 1 | |
| - generare de submultimi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Main { | |
| static int[] perm; | |
| static boolean[] used; | |
| //1 , 3 | |
| static void solve(int level, int n) { | |
| if(level == n + 1) {//4 == 3 + 1= 4 TRUE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //algoritm clasic | |
| public class Main { | |
| static class Solution { | |
| //x = 121 | |
| public boolean isPalindrome( int x ) { | |
| int n = x; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // n = 14 | |
| public class Main { | |
| static class Solution { | |
| public boolean isUgly(int n) { | |
| //n = 123 :3= 41 | |
| int[] factors = { 2, 3, 5 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class BubbleSort { | |
| //Complexitate O(N^2) | |
| public static void BubbleSort(int[] arr) { | |
| int n = arr.length; | |
| for(int i = 0; i < n; i++) { | |
| boolean swapped = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.*; | |
| import java.util.Scanner; | |
| public class Euclid2 { | |
| static int Euclid( int a, int b ) { | |
| while( b != 0) { | |
| int r = a % b; |