用C++实现一个通用的sort函数
问题
用C++实现一个尽可能通用的sort函数
分析
一个通用的sort函数应该包含以下要点:
- 确实可以排序(LOL)
- 可以应对C-style array和C++-style container的排序需求
- 可以应用于任意random access container
- 可以 …
用C++实现一个尽可能通用的sort函数
一个通用的sort函数应该包含以下要点:
Implementation
(n, m) = map(int, raw_input().split())
res = []
for i in xrange(n):
if i % 2 == 0:
res.append('#' * m)
elif (i / 2) % 2 == 0:
res.append('.' * (m - 1) + '#')
else:
res.append('#' + '.' * (m - 1))
for line in res:
print line
DFS …
more ...Simulation.
n = int(raw_input())
g = [[1 for i in xrange(n)] for j in xrange(n)]
for i in xrange(1, n):
for j in xrange(1, n):
g[i][j] = g[i - 1][j] + g[i][j - 1]
print g[n - 1][n - 1]
Brute force.
There are multiple ways to form a 2*2 square at one single step.
So at every step, we have to check the neighbours of pixel that is colored black.
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
#define …
Given a sequence of integer numbers, try to find the median of the sequence.
From Ace of Programming Interview, Cpt1 - Hiring Programmers: The Inside Story
For an interviewee, one the the most efficient way to build a rapport is to try to see things in from the interviewer's perspective.
Ian McAllister, GM at Amazon. I lead the AmazonSmile program.
First, let’s break “getting things done” into two components: “excellent functional skills” and “drive”. Someone with great functional skills but poor drive will not get (enough) things done. Someone with great drive but poor functional skills will not get …
more ...Hey man, I don't know that stuff
Stevey's talking aboooooout
If my boss thinks it's important
I'm gonna get fiiiiiiiiiired
Oooh yeah baaaby baaaay-beeeeee....
熟悉一些 …
more ...