This file contains 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
def findFreePort(): | |
""" | |
函数返回值是当前可用来监听的一个随机端口。 | |
""" | |
import socket | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind(('localhost', 0)) | |
# 用getsockname来获取我们实际绑定的端口号 | |
addr, port = s.getsockname() | |
# 释放端口 |
This file contains 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
import java.util.ArrayList; | |
import java.util.Arrays; | |
public class Solution { | |
public void insert(ArrayList<Integer> heap, int val){ | |
heap.add(val); | |
update(heap, heap.size()-1); | |
} |
This file contains 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
import com.alibaba.fastjson.JSONArray; | |
import com.alibaba.fastjson.JSONObject; | |
import java.util.ArrayList; | |
import java.util.Iterator; | |
public class Solution { | |
public static void main(String[] args) { | |
Solution solution = new Solution(); |
This file contains 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
import java.util.ArrayList; | |
public class Solution { | |
public boolean HasSubtree(TreeNode root1,TreeNode root2) { | |
boolean result = false; | |
if(root1!=null && root2!=null){ | |
result = doesTree1HaveTree2(root1, root2); | |
if(!result){ | |
result = HasSubtree(root1.left, root2); |
This file contains 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
public class Solution { | |
public ListNode Merge(ListNode list1,ListNode list2) { | |
if(list1==null){ | |
return list2; | |
} | |
if(list2==null){ | |
return list1; | |
} | |
ListNode node = new ListNode(0); |
This file contains 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
public class Solution { | |
public void partition(int[] array) { | |
if (array == null || array.length <= 1) { | |
return; | |
} | |
int index1 = 0; | |
int index2 = 0; | |
int index3 = 0; | |
for (int i = 0; i < array.length; i++) { |
This file contains 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<stack> | |
using namespace std; | |
struct ListNode{ | |
int value; | |
ListNode* pNext; | |
}; |
This file contains 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
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
public class JsonParser { | |
private String json; | |
private int index = 0; | |
private Map<Character, Boolean> numChars = new HashMap<>(); |
This file contains 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
/************************************************ | |
* | |
* 全局变量 | |
* | |
* 1. LOG 相关变量和函数 | |
* 2. 延时函数,控制点击速度,寻找最佳的速度,避免被支付宝限制 | |
* 3. 结束函数,自定义结束时候要执行的动作 | |
* 2. 路径和文件相关变量和函数 | |
* | |
************************************************/ |
This file contains 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
# coding=utf-8 | |
import requests | |
import time | |
import os | |
import json | |
import queue | |
import threading | |
import tushare as ts |
NewerOlder