更新一下,关于涂层的问题。主要就是两代:PTFE, PFOA.
新的不沾锅牌子有的说自己有纳米颗粒,比如swiss diamond, 其实就是PTFE材料中混
合了纳米颗粒,该掉还是掉,没意思。
Polytetrafluoroethylene (PTFE)
Back in 1938, there was a fellow by the name of Plunkett who was working for
a chemical company. His job was to make refrigerants using
tetrafluoroethylene gas. He noticed the canister registered empty before it
weighed empty, so, he cut open a canister and discovered a slippery white
waxy coating lining the inside of the tin. In 1945, the Teflon trademark was
register... 阅读全帖
1) difference between c and c++
2) key components in stl
3) what's functor? comparison of function pointer and functor
4) difference between malloc and new
5) how is free(void*) implemented?
6) which methods would be in an empty class?
7) size of an empty class, how about adding one virtual function in empty
class?
8) how is virtual function implemented?
9)
class Base{
virtual g();
};
class Derived{
virtual g();
};
Base* p = new Derived();
p->g(), which g function would be called.
10)
class Base
银行相关的职位,题目比较多,尽量拣记得住的写一下。
1. the difference of new/delete malloc/free. what if new/free, and malloc/
delete?
2. sizeof an empty class
3. sizeof an empty class with virtual function.
4. can we call virtual function in constructor/destructor?
5. what is pure virtual function?
6. How to disable class initialized on heap,
7. How disable class initialized on stack,
8. where static varible saved, heap or stack?(bss, data)
9. what does static mean in C++
10. what is 4 default functions for empty class
... 阅读全帖
How to check the top 2 objects? It seem we can only look at the top
object.
Another question is we have to check N-1 chars from the top of the
stack, where N is the length of the str2. If there are multiple
characters in str2 that are the same as its last char (e.g. accccbc),
then even if str1 is the same as string 2, we have to do extra check 4
times whenever we meet a 'c' in str1.
My idea is to have a companion array recording the maximum matched index
of the char sequence in str1. If there is... 阅读全帖
我的思路是用一个类似于binary tree的图来做的,
开始时只有0 (empty set), 然后左边不加新元素,右边加,
遇到重复就在现有set的基础上加1至cnt+1个,因为我这里的cnt
是从0开始的,程序中就是从0到cnt loop的。
希望能帮助你理解
vector > subsets2(vector &s) {
vector > results;
if (s.empty()) return results;
results.push_back(vector());//init with an empty set
int cnt;
sort(s.begin(), s.end());
for (size_t i=0; i
//compute this first because it will increase during the loop
size_t limit=results.... 阅读全帖
是leetcode的generateParenthesis吗?
写了个dp的
public class Solution {
public ArrayList generateParenthesis(int n) {
// Start typing your Java solution below
// DO NOT write main() function
ArrayList one = new ArrayList();
if (n < 1) return one;
HashMap> dp = new HashMap
ArrayList>();
ArrayList empty = new ArrayList();
empty.add(new String(""));
one.add(... 阅读全帖
int maximalRectangle(vector > &matrix) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
int m = matrix.size();
if (m == 0) {
return 0;
}
int n = matrix[0].size();
vector height;
height.resize(n,0);
stack > st;
int i, j ,answer = 0;
for (i = 0; i < m; ++i) {
for (j = 0; j < n; ++j) {
if (matrix[i][j] == '1') {
++height[j];
... 阅读全帖
armortized 是 O(n) 吧?
两个 stack: s1, s2
s2 is empty.
enque: s1.push
deque: pop s1 to s2 until s1 is empty, s2.pop(). then push s2 back to s1
until s2 is empty
for the amortized time: T(n). firstly T(n) <= O(n)
But we can show T(n) >= \Omega(n)
enque n times, then enque(time cost is 1 ), deque(time cost is 3(n + 1)),
enque(time cose is 1), deque(time cost is 3(n + 1)),...., in this case, the
average time cose >= \Omega(n)
So the amortized cost is O(n)
问过1337哥,他说最大数据是32768*32768,肯定会MLE。
我有个优化的版本,但最后一个test case还是TLE。十分想看谁有能AC的代码!
public boolean isMatch(String s, String p) {
if (s == null || p == null)
return false;
if (s.isEmpty() && p.isEmpty()) { //Both are empty string -> true
return true;
} else if (s.isEmpty()) { // If s is empty, p must not contain
any character other than '*'
for (int i = 0; i < p.length(); i++) {
if (p.charAt(i) != '*')
... 阅读全帖
Given a linked list where in addition to the next pointer, each node has a
child pointer, which may or may not point to a separate list. These child
lists may have one or more children of their own, and so on, to produce a
multilevel data structure, as shown in below figure.You are given the head
of the first level of the list. Flatten the list so that all the nodes
appear in a single-level linked list. You need to flatten the list in way
that all nodes at first level should come first, then nod... 阅读全帖
public class Solution {
public int largestRectangleArea(int[] height) {
// Start typing your Java solution below
// DO NOT write main() function
if(height == null || height.length == 0) return 0;
int n = height.length;
int[] left = new int[n];
Stack stack = new Stack();
int max = 0;
for(int i = 0; i < n; i++){
if(stack.empty() || height[stack.peek()] <= height[i]){
left[i] = i;
... 阅读全帖
攒了个段子请大牛点评一下:
// Not thread-safe
// Talk about validation requirement: none vs in next() vs in constructor
private static class DeepIterator implements Iterator {
private final Iterator
攒了个段子请大牛点评一下:
// Not thread-safe
// Talk about validation requirement: none vs in next() vs in constructor
private static class DeepIterator implements Iterator {
private final Iterator myIterator;
private final Class eleType;
private final Iterator empty = new ArrayList().iterator();
请教leetcode上的那道Word Break II
Given a string s and a dictionary of words dict, add spaces in s to
construct a sentence where each word is a valid dictionary word.
Return all such possible sentences.
For example, given
s = "catsanddog",
dict = ["cat", "cats", "and", "sand", "dog"].
A solution is ["cats and dog", "cat sand dog"]. http://oj.leetcode.com/problems/word-break-ii/
Can anyone tell me why the following code generated Memory Limit Exceeded? I
tested it in VS for that catsanddog string, whic... 阅读全帖
贡献刚做的online test,职位是Machine Learning related。
Question 1 / 2 (LaserMaze)
You are standing in a rectangular room and are about to fire a laser toward
the east wall. Inside the room a certain number of prisms have been placed.
They will alter the direction of the laser beam if it hits them. There
are north-facing, east-facing, west-facing, and south-facing prisms. If the
laser beam strikes an east-facing prism, its course will be altered to be
East, regardless of what direction it had been goi... 阅读全帖
Question 1 / 2 (LaserMaze)
You are standing in a rectangular room and are about to fire a laser toward
the east wall. Inside the room a certain number of prisms have been placed.
They will alter the direction of the laser beam if it hits them. There
are north-facing, east-facing, west-facing, and south-facing prisms. If the
laser beam strikes an east-facing prism, its course will be altered to be
East, regardless of what direction it had been going in before. If it hits
a south-facing prism... 阅读全帖
The Unix Commands
其实就是攒了一下网上的资料
# Create a new tar archive.
# the folder dirname/ is compressed into archive_name.tar
tar cvf archive_name.tar dirname/
# Extract from an existing tar archive
tar xvf archive_name.tar
# View an existing tar archive
tar tvf archive_name.tar
# Search for a given string in a file (case in-sensitive search).
grep -i "the" demo_file
# Print the matched line, along with the 3 lines after it.
grep -A 3 -i "example" demo_text
# Search for a given string in all files recur... 阅读全帖
leetcode上的,感觉如果选择的语言有split这个function,就会好写很多,比如C#和
Java。
C++就麻烦些。而且选择是algorithm 的find还是string的find也很不同。
面试时碰到这类题能说我这道题用C#或者Java,其他用C++行么?其实现在主要用C#,
但C++是总共用得最久的。Java感觉和C#很像,但实际工作中没用过,也不想为面试而
学。多谢
Given an absolute path for a file (Unix-style), simplify it.
For example,
path = "/home/", => "/home"
path = "/a/./b/../../c/", => "/c"
两个C++的
1. string simplifyPath(string path) {
vector a;
int n = path.size();
for (int i = 0; i
{
string t;
... 阅读全帖
void DistanceAround(const vector &rooms, vector> &res,
int i, int k) {
const static int directions[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
res[i][k] = 0;
queue> qu;
qu.push(make_pair(i, k));
while(!qu.empty()) {
int x = qu.front().first;
int y = qu.front().second;
qu.pop();
for (int z = 0; z < 4; ++z) {
int xx = x + directions[z][0];
int yy = y + directions[z][1];
if (0 <= xx && xx < (int)rooms.size()
... 阅读全帖
Given n pairs of parentheses, write a function to generate all combinations
of well-formed parentheses.
For example, given n = 3, a solution set is:
"((()))", "(()())", "(())()", "()(())", "()()()"
递归很容易
void generateParenthesisRecr(string str,int n,int l,int r,vector&
result){
if (l==n && r==n){
result.push_back(str);
return;
}
if (l
if (l>r) generateParenthesisRecr(str+")",n,l,r+... 阅读全帖
You are given 10 empty boxes. You distribute 5 black balls to these empty
boxes so that no two black balls can go into the same box. Now you have 4
white balls and you distribute them in the same fashion but this time a
white ball can go into a box where you put a black ball. That is, in the end
, you might have at least 5 full boxes or at most 9 full boxes. What is the
probability of choosing an empty box?