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> | |
| #include <string> | |
| using namespace std; | |
| //=============================================== | |
| // CLASA ABSTRACTA ANGAJAT | |
| //=============================================== | |
| class Angajat { |
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> | |
| #include <map> | |
| using namespace std; | |
| int main() { | |
| map<int, string> studenti; |
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>//cout,cin | |
| #include <fstream> //fstream | |
| #include <string> | |
| #include <map> | |
| //========================================================= | |
| // CLASA CARTE | |
| //========================================================= | |
| using namespace std; |
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.util.Scanner; | |
| import java.io.*; | |
| /* | |
| Se considera un triunghi de numere naturale format din n linii. | |
| Prima linie contine un numar, a doua linie doua numere...ultima linie n numere naturale. | |
| Cu ajutorul acestui triunghi se pot forma sume de numere naturale in felul urmator: | |
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
| class Solution { | |
| public int climbingStairs(int n) { | |
| int dp[] = new int[n+1]; | |
| Arrays.fill(dp, -1); | |
| return solve(n, dp); | |
| } |
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 | |
| ------------------- | |
| Programarea dinamica (dezvoltata in 1950 de Bellman) esteo tehnica algoritmica ce conduce, de ce le mai multe ori, la un timp de calcul polinomial(O(n^2), O(n)). Spre deosebire de alte tehnici, | |
| ea furnizeaza intotdeauna solutia optima, dar nu se poate aplica oricarei probleme, ci doar celor care indepliplinesc anumite conditii. | |
| Principiul de Optimalitate |
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
| //Floyd's Algorithms Cycle detection - find duplicate Complexity O(n) | |
| class Solution { | |
| public int findDuplicate(int[] nums) { | |
| int slow = nums[0]; | |
| int fast = nums[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
| //solution: log n | |
| //n log n (Array.sort(nums)) | |
| //O(n^2) | |
| //O(n) | |
| class Solution { | |
| //[1,3,4,2,2] | |
| //length = 5 | |
| //low = 1; | |
| //high = 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
| class Solution { | |
| public int findDuplicate(int[] nums) { | |
| Arrays.sort(nums); //quicksort O(n log n) | |
| for(int i = 0; i < nums.length; ++i) { //O(n) | |
| if(nums[i] == nums[i+1]) return nums[i]; |
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; | |
| /* | |
| 1 2 3 | |
| 1 3 2 | |
| ..... | |
| 3 2 1 | |
| n! = 1 * 2 * ... * n | |
| */ |
NewerOlder