Skip to content

Instantly share code, notes, and snippets.

View yuren1978's full-sized avatar

yuren1978

  • Ohio State University
  • Columbus, OH
View GitHub Profile
using System;
using System.Timers;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Topshelf;
namespace TopshelfBootstrapper
{
internal class Program
{
{
"cmd": ["javac", "$file_name"],
"cmd": ["java", "$file_base_name"],
"working_dir": "${project_path:${folder}}",
"selector": "source.java"
}
class Solution {
public:
bool vectorEquals(vector<int>& v1, vector<int>& v2){
if(v1.size()!=v2.size()) return false;
for(int i=0; i<v1.size(); i++){
if(v1[i]!=v2[i])
return false;
}
return true;
}
@yuren1978
yuren1978 / gist:6130165
Created August 1, 2013 10:18
ajacent leetcode
class Solution {
public:
int minValue(const vector<int>& num, int start, int end){
int minValue=num[start];
for(int i=start+1; i<=end; i++){
if(num[i]<minValue){
minValue=num[i];
}
}
return minValue;
@yuren1978
yuren1978 / new_gist_file
Created July 31, 2013 02:19
Leetcode reverse m to n
ListNode *reverseBetween(ListNode *head, int m, int n) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
int count=n-m;
ListNode* prev=new ListNode(0);
ListNode* helper=prev;
prev->next=head;
while(m>1){
prev=prev->next;
m--;
class Solution {
public:
vector<int> computeFromLastRow(const vector<int>& prev, int rowNumber){
vector<int> v;
int middle=(rowNumber%2==0)? rowNumber/2: (rowNumber+1)/2;
for(int i=0; i<middle; i++){
v.push_back(i==0? 1: prev[i-1]+prev[i]);
}
for(int i=middle; i<rowNumber; i++){
@yuren1978
yuren1978 / gist:5691098
Created June 1, 2013 17:25
recover binary tree
class Solution {
public:
TreeNode* first;
TreeNode* second;
TreeNode* prev;
void recoverTreeRecursively(TreeNode* root){
if(root!=NULL){
recoverTreeRecursively(root->left);
@yuren1978
yuren1978 / pathSum
Created June 1, 2013 12:51
pathSumII
class Solution {
public:
void getPathSum(TreeNode* root, vector<vector<int> >& v, vector<int>& currentV, int currentSum, int sum){
if(currentSum==sum){
v.push_back(currentV);
return;
}
if(root
@yuren1978
yuren1978 / gist:5631916
Last active December 17, 2015 15:29
rotate image
class Solution {
public:
while(startCol+step < endCol){
int temp=matrix[startRow][startCol+step];
matrix[startRow][startCol+step]=matrix[endRow-step][startCol];
matrix[endRow-step][startCol]=matrix[endRow][endCol-step];
matrix[endRow][endCol-step]=matrix[startRow+step][endCol];
matrix[endRow-bottomRow][endCol]=temp;
step++;
}
Sublime Text 2 - Default shortcuts cheatsheet (PC keyboard)
-----------------
General
-----------------
* Go to file (CTRL + P)
* Go to project (CTRL + ALT + P)
* Go to methods (CTRL + R)
* Go to line (CTRL + G)
* Toggle side bar (CTRL + KB)