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 'package:flutter/cupertino.dart'; | |
void main() => runApp(const MyApp()); | |
enum Direction { | |
up('UP'), down('DOWN'), left('LEFT'), right('RIGHT'); | |
final String title; | |
const Direction(this.title); |
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import codecs | |
import regex | |
import sys | |
def join_cjk(s): | |
cjk = r'([\p{CJK Unified Ideographs}\p{Halfwidth and Fullwidth Forms}])' | |
pattern = cjk + r'\n *' + cjk |
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
/** | |
* 陈利人老师微博面试编程题:一个有序数组(从小到大排列),数组中的数据有正有负, | |
* 求这个数组中的最小绝对值。 | |
* | |
* Sample Input | |
* | |
* -4 -2 -1 2 3 5 | |
* -2 0 3 5 8 | |
* -8 -6 -3 -2 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
/* | |
* 问题:给定一个由 0 和 1 组成的二维数组,求连通分量的个数。 | |
* | |
* 思路:可以把该二维数组看成是一个图,1 代表结点,上下左右相邻的 1 表示 | |
* 结点之间相连,然后用 DFS 或 BFS 遍历该图,就可以得到连通分量的个数。 | |
*/ | |
#include <iostream> | |
#include <vector> | |
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 <queue> | |
#include <algorithm> | |
using namespace std; | |
template<typename T> | |
class MyContainer { | |
public: | |
void insert(const T& val); |
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 <limits> | |
struct Node { | |
long data; | |
Node *lchild; | |
Node *rchild; | |
}; |
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
/* | |
* 表达式求值(http://www.bianchengla.com/course/ds/practise/problem?id=1322) | |
* | |
* 时间限制:1000 ms 内存限制:65536 KB | |
* | |
* 描述 | |
* | |
* 给一些包含加减号和小括号的表达式,求出该表达式的值。表达式中的数值均为 | |
* 绝对值小于 10 的整数。 | |
* |
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
/* | |
* 二十四点游戏 | |
* | |
* 时间限制:1000 ms 内存限制:8196 KB | |
* | |
* 描述 | |
* | |
* 算二十四点是个很好玩的扑克牌游戏,给 4 张的 A 至 K 的扑克牌,分别代表 1~13, | |
* 随意组合这四张牌,只使用 +, -, *, / 的四则运算,不使用其他运符和括号。 | |
* 请判断给定的四张牌是否可以算出二十四点。 |
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
#! /usr/bin/python | |
# coding: UTF-8 | |
import sys | |
def main(): | |
a = [] | |
for line in sys.stdin: | |
a.append(int(line)) | |
print count_inversions(a, 0, len(a) - 1) |