新浪是中国的门户网站公司,一家中文网络内容服务提供商;新浪网的前身是广东人王志东的四通利方公司,王志东曾连续 3 次到美国硅谷“寻宝”,确定开展全球华人互联网网站业务为公司今后主要发展方向。新浪网也在他的领导下成为曾经三大门户中绝对的大哥。
除了创建新浪网以外,王志东还有过以下哪一项重要成就?
A | 第一个写出 Windows 中文平台的程序员 |
B | 第一个开设中国新闻网站的程序员 |
C | 第一个创建个人主页的程序员 |
D | 第一个上《时代》杂志的中国程序员 |
答案:第一个写出 Windows 中文平台的程序员
美国最大的点评网站是 Yelp,它于 2004 年的 10 月 13 日在旧金山起步,囊括各地餐馆、购物中心、酒店、旅游等领域的商户,用户可以在 Yelp 网站中给商户打分,提交评论,交流购物体验等。
Yelp 网的诞生时间和中国的大众点评相差几年?
A | 比大众点评晚 2 年 |
B | 和大众点评同年诞生 |
C | 比大众点评晚 1 年 |
D | 比大众点评早 1 年 |
答案:比大众点评晚 1 年
Slackware Linux 是目前市场存活时间最长的 Linux 发行版之一,它基于一个叫做 SLS(Soft Landing Systems)的 Linux 项目而设计,易于使用和稳定。
Slackware Linux 的创始人是谁?
A | Patrick Schueffel |
B | Patrick Drahi |
C | Patrick Loubert |
D | Patrick Volkerding |
答案:Patrick Volkerding
给你一个整数 columnNumber
,返回它在 Excel 表中相对应的列名称。
例如:
- A -> 1
- B -> 2
- C -> 3
- ...
- Z -> 26
- AA -> 27
- AB -> 28
- ...
示例 1:
输入:columnNumber = 1 输出:"A"
示例 2:
输入:columnNumber = 28 输出:"AB"
示例 3:
输入:columnNumber = 701 输出:"ZY"
示例 4:
输入:columnNumber = 2147483647 输出:"FXSHRXW"
提示:
1 <= columnNumber <= 231 - 1
A | #include using namespace std; class Solution { public: string convertToTitle(int n) { string res; while (temp) { int temp = n % 26; n /= 26; if (n) res.push_back('A' + temp - 1); else { res.push_back('Z'); n--; } } reverse(res.begin(), res.end()); return res; } }; |
B | #include using namespace std; class Solution { public: string convertToTitle(int n) { string res; while (n) { int temp = n % 26; n /= 26; if (n) res.push_back('A' + temp - 1); else { res.push_back('Z'); n--; } } reverse(res.begin(), res.end()); return res; } }; |
C | #include using namespace std; class Solution { public: string convertToTitle(int n) { string res; while (temp) { int temp = n % 26; n /= 26; if (temp) res.push_back('A' + temp - 1); else { res.push_back('Z'); n--; } } reverse(res.begin(), res.end()); return res; } }; |
D | 以上都不对 |
答案:
- #include
- using namespace std;
- class Solution
- {
- public:
- string convertToTitle(int n)
- {
- string res;
- while (n)
- {
- int temp = n % 26;
- n /= 26;
- if (temp)
- res.push_back('A' + temp - 1);
- else
- {
- res.push_back('Z');
- n--;
- }
- }
- reverse(res.begin(), res.end());
- return res;
- }
- };
举例如下:一个数组{915,941,960,976,992,1015,1034,1050,1073,1089,1115,1131,1150,1166,1182,1208,1227};目标值假设是1000,最接近元素为992,下标为4
以下程序实现了这一功能,请你填补空白处内容:
- #include
- int main()
- {
- int min = (1 << 31) - 1;
- int idx = 0;
- int arr[] = {915, 941, 960, 976, 992, 1015, 1034, 1050, 1073, 1089, 1115, 1131, 1150, 1166, 1182, 1208, 1227};
- int n = 1000;
- for (int i = 0; i < sizeof(arr) / sizeof(int); i++)
- {
- int diff = arr[i] - n;
- if (diff < 0)
- diff = -diff;
- _________________;
- }
- printf("最接近的是%d 下标是%d", arr[idx], idx);
- return 0;
- }
A | if (diff < min) { min = diff; idx = i; } |
B | if (diff > min) { min = diff; idx = i; } |
C | if (diff == min) { min = diff; idx = i; } |
D | if (diff >= min) { min = diff; idx = i; } |
答案:
- if (diff < min)
- {
- min = diff;
- idx = i;
- }
根据一棵树的中序遍历与后序遍历构造二叉树。
注意:
你可以假设树中没有重复的元素。
例如,给出
中序遍历 inorder = [9,3,15,20,7] 后序遍历 postorder = [9,15,7,20,3]
返回如下的二叉树:
A | #include using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; class Solution { public: TreeNode *buildTree(vector { if (0 == inorder.size() || 0 == postorder.size()) { return NULL; } return build(inorder, 0, inorder.size() - 1, postorder, 0, postorder.size() - 1); } TreeNode *build(vector { TreeNode *root = new TreeNode(postorder[p2]); int i = i1; while (i <= i2 && postorder[p2] != inorder[i]) { i++; } int left = i - i1; int right = i2 - i; if (i <= i2 && postorder[p2] != inorder[i]) { root->left = build(inorder, i1, i - 1, postorder, p1, p1 + left - 1); } if (right > 0) { root->right = build(inorder, i + 1, i2, postorder, p1 + left, p2 - 1); } return root; } }; |
B | #include using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; class Solution { public: TreeNode *buildTree(vector { if (0 == inorder.size() || 0 == postorder.size()) { return NULL; } return build(inorder, 0, inorder.size() - 1, postorder, 0, postorder.size() - 1); } TreeNode *build(vector { TreeNode *root = new TreeNode(postorder[p2]); int i = i1; while (i <= i2 && postorder[p2] != inorder[i]) { i++; } int left = i - i1; int right = i2 - i; if (left > 0) { root->left = build(inorder, i1, i - 1, postorder, p1, p1 + left - 1); } if (right > 0) { root->right = build(inorder, i + 1, i2, postorder, p1 + left, p2 - 1); } return root; } }; |
C | #include using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; class Solution { public: TreeNode *buildTree(vector { if (0 == inorder.size() || 0 == postorder.size()) { return NULL; } return build(inorder, 0, inorder.size() - 1, postorder, 0, postorder.size() - 1); } TreeNode *build(vector { TreeNode *root = new TreeNode(postorder[p2]); int i = i1; while (i <= i2 && postorder[p2] != inorder[i]) { i++; } int left = i - i1; int right = i2 - i; if (right > 0) { root->left = build(inorder, i1, i - 1, postorder, p1, p1 + left - 1); } if (right > 0) { root->right = build(inorder, i + 1, i2, postorder, p1 + left, p2 - 1); } return root; } }; |
D | #include using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; class Solution { public: TreeNode *buildTree(vector { if (0 == inorder.size() & 0 == postorder.size()) { return NULL; } return build(inorder, 0, inorder.size() - 1, postorder, 0, postorder.size() - 1); } TreeNode *build(vector { TreeNode *root = new TreeNode(postorder[p2]); int i = i1; while (i <= i2 && postorder[p2] 0 <= = inorder[i]) { i++; } int left = i - i1; int right = i2 - i; if (left > 0) { root->left = build(inorder, i1, i - 1, postorder, p1, p1 + left - 1); } if (right > 0) { root->right = build(inorder, i + 1, i2, postorder, p1 + left, p2 - 1); } return root; } }; |
答案:
- #include
- using namespace std;
- struct TreeNode
- {
- int val;
- TreeNode *left;
- TreeNode *right;
- TreeNode(int x) : val(x), left(NULL), right(NULL) {}
- };
- class Solution
- {
- public:
- TreeNode *buildTree(vector<int> &inorder, vector<int> &postorder)
- {
- if (0 == inorder.size() || 0 == postorder.size())
- {
- return NULL;
- }
- return build(inorder, 0, inorder.size() - 1, postorder, 0, postorder.size() - 1);
- }
- TreeNode *build(vector<int> &inorder, int i1, int i2, vector<int> &postorder, int p1, int p2)
- {
- TreeNode *root = new TreeNode(postorder[p2]);
- int i = i1;
- while (i <= i2 && postorder[p2] != inorder[i])
- {
- i++;
- }
- int left = i - i1;
- int right = i2 - i;
- if (left > 0)
- {
- root->left = build(inorder, i1, i - 1, postorder, p1, p1 + left - 1);
- }
- if (right > 0)
- {
- root->right = build(inorder, i + 1, i2, postorder, p1 + left, p2 - 1);
- }
- return root;
- }
- };