Skip to content

Commit

Permalink
【add】笔试-iHandy-180927
Browse files Browse the repository at this point in the history
  • Loading branch information
imhuay committed Sep 27, 2018
1 parent 7b67776 commit 9140e68
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
78 changes: 78 additions & 0 deletions D-笔试面经/笔试-iHandy-180927.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
笔试-iHandy-180927
===
- 单项选择题 8 道,不定项选择题 5 道,问答题 2 道,编程题 1 道

Index
---
<!-- TOC -->

- [【问答】射击(概率题)](#问答射击概率题)
- [【编程】比大更大](#编程比大更大)

<!-- /TOC -->

## 【问答】射击(概率题)

**问题描述**
```
假设有一支手枪,每次扣动扳机,有 50% 的概率发射子弹;
现甲和乙轮流使用该手枪想对方射击,直到其中一方中弹;
问甲先射击,乙先中弹的概率?
```


## 【编程】比大更大
> 剑指 Offer:[把数组排成最小的数](https://www.nowcoder.com/practice/8fecd3f8ba334add803bf2a06af1b993?tpId=13&tqId=11185&tPage=2&rp=2&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
<div align="center"><img src="../_assets/TIM截图20180927103607.png" height="" /></div>
<div align="center"><img src="../_assets/TIM截图20180927103625.png" height="" /></div>
**贪心**(80%)
```python
n = int(input())

s = []
for _ in range(n):
s.append(input())

s.sort(reverse=True)
#print(s)

ans = ''.join(s)

print(int(ans))
```

**自定义排序**(80%)
```C++
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>

using namespace std;

string foo(vector<string> ns) {
sort(ns.begin(), ns.end(), [](const string &l, const string &r){
return r + l < l + r;
});

stringstream ss;
for (auto i : ns)
ss << i;

return ss.str();
}

int main() {

int n;
cin >> n;
vector<string> ns(n);
for (int i=0; i < n; i++)
cin >> ns[i];

cout << foo(ns);
return 0;
}
```
10 changes: 10 additions & 0 deletions ToDo.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ Updates Log
- 一阶 二阶泰勒展开
- 梯度下降往往没有指向

## 2018-9-27
- 笔试 - iHandy

## 2018-9-26
- 算法 - 专题 - 双指针

## 2018-9-25
- 算法 - 专题 - 双指针
- 笔试 - 作业帮

## 2018-9-24
- 算法 - 专题 - 双指针

Expand Down
Binary file added _assets/TIM截图20180927103607.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _assets/TIM截图20180927103625.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9140e68

Please sign in to comment.