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
class MyRunner implements Runnable { | |
public void run() { | |
System.out.println(Thread.currentThread().getName() + ":连接数据库..."); | |
Connection connection = null; | |
try { | |
connection = DriverManager.getConnection(RepeatableRead.DB_URL, RepeatableRead.USER, RepeatableRead.PASS); | |
connection.setAutoCommit(false); | |
//connection.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); | |
connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); | |
String querySql = "select * from account where id=?"; |
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 <unordered_map> | |
#include <queue> | |
#include <sstream> | |
/* | |
* 阿里巴巴2017实习生招聘在线编程测验--基础平台研发工程师 | |
* 思路:使用邻接矩阵表示图, 因为地理位置不超过100,所以可以先建立起一个 100x100 的矩阵 | |
* 然后读入数据,依次建立矩阵(使用两个哈希表建立起地理位置和下标的对应关系) | |
* 建立完成后,使用 Dijkstra 算法算出最短路径,注意使用一个数组保存 |
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
from collections import Iterable | |
def flatten(items, ignore_types=(str, bytes)): | |
"""flatten a nested sequence | |
implement it based on Python Cookbook(version 3) 4.14 Flattening a Nested Sequence""" | |
for x in items: | |
if isinstance(x, Iterable) and not isinstance(x, ignore_types): | |
yield from flatten(x, ignore_types) | |
else: |