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
| // A ^ B = A + B - 2(A&B) ..... | |
| // https://algospot.com/judge/problem/read/XORNECKLACE | |
| // time complexity : O(n) | |
| // space complexity : O(500) | |
| #include <stdio.h> | |
| #define MAX_SIZE 500 | |
| long long int xorNeclaceMaxValue(void) { |
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
| //http://codercareer.blogspot.kr/2011/11/no-24-intersection-of-sorted-arrays.html | |
| //timecomplexity : O(nlogm) | |
| //spacecompexity : O(n)? | |
| #include <vector> | |
| #include <iostream> | |
| #include <algorithm> | |
| int arr1[7] = {1, 3, 5, 7, 9, 10, 15}; | |
| int arr2[5] = {3, 5, 7, 11, 16}; |
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
| // https://algospot.com/judge/problem/read/LECTURE | |
| // Time Complexity : O(nlogn) | |
| // Space Complexity : O(n) | |
| #include <string> | |
| #include <vector> | |
| #include <iostream> | |
| #include <algorithm> | |
| 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
| // http://codercareer.blogspot.kr/2013/02/no-37-missing-number-in-array.html | |
| // problem1 => time complexity : O(N), space complexity : O(2) | |
| // problem2 => time complexity : O(logN), space complexity : O(3) | |
| #include <iostream> | |
| #include <assert.h> | |
| 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
| // https://algospot.com/judge/problem/read/JOSEPHUS | |
| // time complexity O(kN) | |
| // space complexity O(N) | |
| #include <stdio.h> | |
| #include <list> | |
| using namespace std; | |
| void findAlivePerson(int n, int k) { |
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
| //http://codercareer.blogspot.kr/2011/11/no-19-left-rotation-of-string.html | |
| // time complexity : O(n) | |
| // space complexity : O(n) | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| void Reverse(char *pBegin, char *pEnd) { | |
| if(pBegin == NULL || pEnd == NULL) |
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
| //http://codercareer.blogspot.kr/2011/11/no-22-turning-number-in-array.html | |
| //timecost : O(logN) | |
| #include <assert.h> | |
| #include <stdio.h> | |
| int findTurningNumber(int * array, int length) { | |
| if (array == NULL || length <= 2) | |
| return -1; |
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
| //http://codercareer.blogspot.kr/2011/09/no-03-maximum-sum-of-all-sub-arrays.html | |
| #include <stdio.h> | |
| #include <algorithm> | |
| #include <assert.h> | |
| using namespace std; | |
| int findMaximumSumOfSubArray(int *array, int length) { | |
| if (array == NULL || length <= 0) { | |
| printf("wrong input \n"); |
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
| //http://codercareer.blogspot.kr/2014/09/no-55-translating-numbers-to-string.html | |
| #include <iostream> | |
| #include <string> | |
| #include <assert.h> | |
| using namespace std; | |
| int getTransCount(string number) { | |
| if (atoi(number.c_str()) <= 0) | |
| return 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
| //http://codercareer.blogspot.kr/2013/02/no-44-maximal-stolen-values.html | |
| #include <stdio.h> | |
| #define ARRAY_MAX 10 | |
| #define MAX(a, b) (((a) > (b)) ? (a) : (b)) | |
| int findMaxStolenValue(int *array, int size) { | |
| if (size == 0) | |
| return 0; |