Skip to content

Instantly share code, notes, and snippets.

View superlayone's full-sized avatar
👻

superlayone superlayone

👻
  • Ant Group,Zhima Enterprise Credit
  • Yuan Space,Zhejiang,Hangzhou,China
View GitHub Profile
#! /usr/bin/env python
# coding=utf-8
__author__ = 'jszhou'
from bottle import *
import hashlib
import xml.etree.ElementTree as ET
import urllib2
# import requests
import json
@superlayone
superlayone / AddNewWeightFunc.md
Last active August 29, 2015 13:57
Nova scheduler weight function

change to directory

cd /usr/share/pyshared/nova/scheduler/weights

add a new weight function

vim disk.py

go to bin directory

cd /usr/lib/python2.7/dist-packages/nova/scheduler/weights
@superlayone
superlayone / wandoujia-1.md
Last active August 29, 2015 13:57
豌豆荚面试

打印mxn螺旋矩阵

	class Solution {      
	public:      
	    vector<int> spiralOrder(vector<vector<int> >& matrix) {      
	        vector<int> result;      
	        if (matrix.empty()) return result;      
	        ssize_t beginX = 0, endX = matrix[0].size() - 1;      
	        ssize_t beginY = 0, endY = matrix.size() - 1;      
@superlayone
superlayone / wandoujia-other.md
Last active August 29, 2015 13:57
这是宿舍人面试豌豆荚的一道题,正好没做过,拿来做做

Minimum Window Substring

这是宿舍人面试豌豆荚的一道题,正好没做过,拿来做做

Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).

For example, S = "ADOBECODEBANC" T = "ABC" Minimum window is "BANC".

@superlayone
superlayone / deepCopyList.md
Last active August 29, 2015 13:57
链表的深拷贝问题

一个链表有一个int数据域,一个next指针域,一个random指针域,random要么指向一个随机的node,要么置空,对此链表进行深拷贝

	/**
	 * Definition for singly-linked list with a random pointer.
	 * struct RandomListNode {
	 *     int label;
	 *     RandomListNode *next, *random;
	 *     RandomListNode(int x) : label(x), next(NULL), random(NULL) {}
	 * };
@superlayone
superlayone / tencentInternship2014.md
Last active August 29, 2015 13:57
腾讯2014实习生招聘笔试

腾讯2014实习生笔试

1、有四个人,四顶帽子,两个黑色,两个白色,说出自己帽子颜色的释放,否则死亡,每个人只能看前方不能看后方,位置如下:

	>W	
<B	|	>B
|	|	|	>W
|	|	|	|
A	B	C	D
@superlayone
superlayone / LRU.md
Last active August 29, 2015 13:57
设计一个LRU缓存

设计一个LRU缓存,支持如下操作

get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.

set(key, value) - Set or insert the value if the key is not already present. When the cache reached its capacity, it should invalidate the least recently used item before inserting a new item.

思路

哈希表存储映射关系可以在O(1)时间内实现快速查找,利用双向链表存储节点信息,O(1)时间内交换节点。头结点保存最近使用的,尾节点保存最近最少使用的,get时更新最近使用节点(即将当前节点更新至头结点)

@superlayone
superlayone / wandoujia-2nd.md
Last active August 29, 2015 13:57
豌豆荚的第二次面试

豌豆荚二面

总的来说还是不错的。以下说说面试的内容(容我吐槽面试官的电话信号太烂了,听不清楚,还有不挂代理的gmail进去太慢了)

1、首先问了我项目上的有些事情,很快就过去了

@superlayone
superlayone / reverseListBetweenMandN.md
Last active July 10, 2019 12:53
Reverse a linked list from position m to n in-place and in one-pass.

##Leetcode-Reverse Linked List II##

Reverse a linked list from position m to n. Do it in-place and in one-pass.

For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4,

return 1->4->3->2->5->NULL.

Note: Given m, n satisfy the following condition:

@superlayone
superlayone / wandoujia-beijing-3rd.md
Last active August 29, 2015 13:59
豌豆荚北京现场面

豌豆荚的北京现场面

高效地、线程安全地实现C++单例

首先我目前只会加锁机制版本的,不知道是不是面试官特意强调的高效版
	//Singleton.h
	class Singleton
	{
		public:
			static Singleton* GetInstance();
 private: