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
package lrucache | |
type LRUCacheNode struct { | |
Key int | |
Val int | |
Next *LRUCacheNode | |
Prev *LRUCacheNode | |
} | |
type LRUCache struct { |
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
#define glCheckError() glCheckError_(__LINE__) | |
void glCheckError_(int line) { | |
GLenum errorCode; | |
char error[100]; | |
memset(error, 0, sizeof(error)); | |
while ((errorCode = glGetError()) != GL_NO_ERROR) { | |
switch (errorCode) { | |
case GL_INVALID_ENUM: sprintf_s(error, "GL_INVALID_ENUM"); break; | |
case GL_INVALID_VALUE: sprintf_s(error, "GL_INVALID_VALUE"); break; |
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
void rgb24ToBMP(unsigned char *rgbBuffer, int width, int height, const char *bmppath) { | |
typedef struct { | |
long imageSize; | |
long blank; | |
long startPosition; | |
} BmpHead; | |
typedef struct { | |
long Length; | |
long width; |
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
void NV12ToBGR24(uint8_t* pYUV, uint8_t* pBGR24, int width, int height) { | |
if(width < 1 || height < 1 || pYUV == NULL || pBGR24 == NULL) | |
return; | |
const long len = width * height; | |
unsigned char* yData = pYUV; | |
unsigned char* vData = &yData[len]; | |
unsigned char* uData = &vData[len >> 2]; | |
int bgr[3]; | |
int yIdx, uIdx, vIdx, idx; |
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 <algorithm> | |
using namespace std; | |
typedef struct ListNode { | |
int val; | |
struct ListNode *next; | |
ListNode(int val):val(val) {} |
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 search(vector<int>& nums, int target) { | |
int size = nums.size(); | |
int low = 0, high = size; | |
while(low < high) { | |
int mid = low + (high-low)/2; | |
if (nums[mid] == target) { | |
return mid; | |
} |
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
/** | |
* Definition of TreeNode: | |
* class TreeNode { | |
* public: | |
* int val; | |
* TreeNode *left, *right; | |
* TreeNode(int val) { | |
* this->val = val; | |
* this->left = this->right = 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
#include <iostream> | |
#include <cstdlib> | |
/** | |
* 小顶堆 | |
*/ | |
void heapInsert(int *heap, int n, int num) { | |
int i, j; | |
heap[n] = num; | |
i = n; | |
j = (n - 1) / 2; |
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 Solution1 { | |
public: | |
/** | |
* @param A: an integer rotated sorted array | |
* @param target: an integer to be searched | |
* @return: an integer | |
*/ | |
int search(vector<int> &A, int target) { | |
int size = A.size(); | |
if (size == 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
// 加法 | |
int getSum(int a, int b) { | |
int sum = 0; | |
while(b != 0) { | |
sum = a ^ b; | |
b = (a & b) << 1; | |
a = sum; | |
} | |
return sum; | |
} |
NewerOlder