Skip to content

Instantly share code, notes, and snippets.

#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(), x.end()
typedef long long int lld;
typedef pair<int, int> pii;
void encode(int x, string &str)
/*
GDB online Debugger
https://www.onlinegdb.com/
*/
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(), x.end()
@tratitude
tratitude / build_win.cmd
Created April 9, 2019 04:11
caffe-windows branch
@echo off
@setlocal EnableDelayedExpansion
:: Default values
if DEFINED APPVEYOR (
echo Setting Appveyor defaults
if NOT DEFINED MSVC_VERSION set MSVC_VERSION=14
if NOT DEFINED WITH_NINJA set WITH_NINJA=0
if NOT DEFINED CPU_ONLY set CPU_ONLY=0
if NOT DEFINED CUDA_ARCH_NAME set CUDA_ARCH_NAME=Auto
@setlocal
@echo off
if NOT EXIST build_v140_x64 (
mkdir build_v140_x64
)
pushd build_v140_x64
:: Setup the environement for VS 2015 x64
call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" amd64
:: configure
@tratitude
tratitude / task.json
Created March 25, 2019 09:23
vscode linux gcc
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "gcc",
"args": [
@tratitude
tratitude / launch.json
Created March 25, 2019 09:21
vscode linux-gcc
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/${fileBasenameNoExtension}.o",
"args": [],
class Solution {
public:
int lengthOfLongestSubstring(string s) {
int i, j;
int maxLen=0;
int maxIndex=0;
int sLen = s.length();
int substringLen=0;
for(i=0; i<sLen; i++){
@tratitude
tratitude / LeetCode_1. Two Sum_1.cpp
Created May 13, 2018 08:42
Approach#3 hash table
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
map<int, int> hashTable;
vector<int> outVec;
int i;
for(i=0; i<nums.size(); i++){
map<int, int>::iterator it = hashTable.find(target-nums[i]);
if(it != hashTable.end()){
outVec.push_back(it->second);
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
@tratitude
tratitude / BinaryTree.cpp
Created May 13, 2018 06:18
LeetCode-play ground
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/