Ciel's blog

Hi, this is Ciel!

Source

难点:语速

Structure

2020-11-17_14-47-16

Dictation

I was not one of those kids that know exactly what they wanted to do when they were grown up. In fifteen years of my career, I’ve been English teacher, attorney, video game creator, and now a toilet paper salesman sales millions of rows of toilet paper a year.

Life is about finding the intersection of what you really really love with what you really really good at. As simple as it sounds, it’s really not that easy to find. After a brief stand as an English teacher I went to a law school and ended up becoming attorney at a really big law firm here in New York City. Like most Americans, for the next two to three years, I was holding on to my job for dear life, worked really late hours at a job that I thought maybe I was good at but certainly not one that I really really love. I then came upon that epiphany, that takes years if not tens of thousands of hours to get really good at something. I really didn’t have a lot of time to waste.

This talk isn’t for those looking to quit their job because they don’t like their boss or they had a long day of work. This is for those who are ready to make the completely scary leap into a brand new career. So, as you think about making a career change, here are a few tips I hope you can consider and a few things I’ve picked up along the way.

First, there are three things to think about before you’re ready to move on. No. one, professional life is about learning. If you are not even interested in learning anymore, that’s a huge red flag that there might not be a future for you in that industry. No. two, career changes are often gut driven, if you constantly have sleepless night or you just right awake and staring at the ceiling, thinking “Oh, man, I can’t live with myself if I never try to make this change or if I don’t even actually investigate it.” Then trust your gut. It might be time for that career change. On the flip side, one reason to not move on is short-term pain. If you don’t like your boss, or people at the office at grating on you. That’s actually not a really good reason to absolutely change your career because when you do change a career you generally have to start from the bottom and you’ll probably feel a lot of short-term pain whether it’s through a lack of salary or a lack of tittle, pain at any job is inevitable.

So, now you are convinced it’s time to change the career. Then there are three things to do immediately. First, network, network, network. No one ever builds a good career without a good mentor or good support network. What I mean by networking is getting all the great advice you can possibly get. Technology has make it so simple to reach out to new people to say “Hey, I’m thinking about making a career change. Do you have five minutes to chat with me?” That passion, that hunger and that ability to be a sponge really attracts awesome mentors and people willing to give you their time to give you some good advice. Let’s go out there and meet new people. The second thing you need to do immediately is to shore up your finances. The reality is when you change your career, you’ll’ either start with a job with a lower tittle or lower pay or maybe even no pay, especially if you’re starting your own business. So, going out there and making sure your finances are in order to make the transition less painful is really really important. For me personally, as I made the transition from being an attorney over to a video game creator, I wanted to have at least six to twelve months of personal runway in the bank. You know, six to twelve months, might not be the right number for you, but be honest with yourself, what that number should be? No. three, if you are not ready to make the full jump right at this moment, then get your side hustle on. Side hustles could be any thing from volunteering with an organization that’s in that industry you wanna go into, could be starting your business part-time on the weekends. It’s a free way to get a taste to see if you really really love something.

So you are ready to make the move or maybe you already made the move, Here are three things you should think about doing right now. One, don not, I repeat, do not burn bridges. You spent years building that bridge, why burn them now? The world is such a small place especially with all these online platforms, that believe me, you’ll see these people again and probably in the most inopportune times. No. two, take stock of what you’ve learnt in your previous career or careers. Most likely, a lot of those things are applicable to your new jobs or new career. There is interacting with people, playing on a team, or whether it’s dealing with jerks or dealing with assholes, All those things are universally applicable. You’ll find jerks no matter what industry you’re in, No one is immune to it. Everyone’s got figure it out, and you probably know how to do it already. And lastly, when you start your new job, I know you’re gonna be nervous, but don’t worry, take a deep breath, because this is what I wanna tell you. You are part of a new team now, and everyone around you is rooting for your success, because your success is their success. So welcome to your new career.

Notes

  • attorney /ə’tɝni/

    attorney: 主要用于美国,指代理当事人处理遗嘱检验等法律事务的律师,有时可与lawyer通用,泛指辩护律师。
    lawyer: 普通用词,指精通法律规则并有权以法律代理人或顾问身份在法庭上执行法律或为委托人服务的人。
    counsel: 指单独或集体为当事人提供咨询或出庭处理案件的法律顾问或律师。
    advocate: 专指以罗马法律的基本法制的一些国家的(如苏格兰等)和一些特别法庭的律师;也可指出庭辩护的律师。

  • epiphany /ɪ’pɪfəni/

    n. 主显节(每年一月六日纪念耶稣显灵的节日);显现(特指神的显现)

    I had an Epiphany recently.
    最近,我有一种顿悟。

  • come upon

    要求;成为…的负担;突然产生;碰到

    An ingenious idea suddenly came upon him.
    他突然想到了一个绝妙的主意

    But one day a misfortune came upon her.
    但有一天,不幸降临在她身上。

    Along the way, they came upon a black bear.
    在路上,他们遇到了一只黑熊。

  • grate on

    刺激;激怒

    I read an article recently, they were saying that Australian accents grate on them.
    我最近读了一篇文章,他们说澳大利亚口音让他们很烦。

    grate vt. 装格栅于;磨擦; vi. 发摩擦声; n. 壁炉;格栅

  • convinced

    adj. 确信的

  • mentor

    注意发音:UK:/‘mentɔ:/ US:/ˈmɛnˌtɔr/

  • sponge

    /spʌndʒ/ n. 海绵;vt. (用海绵或海绵状物)擦拭, 清除;vt. & vi. 骗取; 敲詐; 揩油

    when use ‘sponge’ to describe a person, it can be positive or negative.

    positive: people who observe their surroundings in detail, or people really good at the memory game. It’s a descriptor for people who take in information quickly and with ease, or someone who can retain a lot of information. Children, young people or exceptionally bright people may be described as sponges since they can “soak up” information and retain it. Basically, an informal way to refer to an intelligent person.

    negative: somebody who frequently benefits from the generosity of others but never returns the favour. Lazy people may be referred to as sponges because they “soak up” tax payer money for their own selfish ends without contributing anything positive in return. An example of people like this are the Northern Irish Loyalists. Even Harold Wilson himself referred to them as spongers.

  • shore up

    支持,支撑;加固 support by placing against something solid or rigid

    Aid agencies are racing to shore up flimsy shelters
    多个援助机构正在争分夺秒地为随时可能崩塌的避难所提供支持,

    This initially earmarked 700 billion dollars to shore up the banks.
    这一计划最初拨出7000亿美元来支撑银行。

  • runway

    跑道

    A financial runway can be defined as the number of months or years that you can survive without the need to actively work and earn wages.

  • side hustles

    副业

  • inopportune

    adj. 不凑巧的;不合时宜的

    Yet falling stock-markets and financial mayhem make it an inopportune time for dealmaking.
    然而,股市下跌和金融混乱使得现在不是做交易的好时机。

  • take stock of

    估量,清查, 鉴定, 估计

    Americans from Virginia to Massachusetts and every state in between are taking stock of the damage from a Nor’easter.
    从弗吉尼亚州至马萨诸塞州及两州之间的所有州都将对东北风暴的破坏程度进行分析。

    But now he had got a grip on himself, had stopped, and was taking stock of himself and the situation.
    但是现在他控制住了自己的情绪,停了下来,开始估量自己的处境。

    stock : vt. 储备, 保持…的供应

  • root for

    支持;赞助;为……加油

    Indeed, instead of fighting the newcomer, incumbent exchanges should be rooting for it.
    确实,与其与新来者竞争,现有交易所应该支持它。

题目

输入数字n, 按顺序打印出从1 最大的n 位十进制数。比如输,则打印出1 、2 、3 一直到最大的3 位数即999 。

1
2
输入: n = 1
输出: [1,2,3,4,5,6,7,8,9]

解题

此题目主要考察某些编程语言(JAVA/C/C++等)存在的大数问题

直接法

直接法只能用于一些不存在大数问题的语言,如Python。

为什么Python没有大数问题:

refs:

深度剖析凭什么python中整型不会溢出

Python 3 的 int 类型详解(为什么 int 不存在溢出问题?)

1
2
3
class Solution:
def printNumbers(self, n):
return [i for i in range(1,10**n)]

字符串模拟加法

最常用也是最容易的方法是用字符串或者数组表达大数。

字符串里每个字符都是09之间的某一个字符,用来表示数字中的一位。这里用一个长度为n+1的字符串来表示数字,第0位(也即最高位)用来表示溢出的进位(《剑指offer》中则是最高位用的\0表示结束符,也就是个空格;判断是否溢出是判断加法计算后第0位是否>10)。当实际数字不够n 位的时候,在字符净的前半部分补0 。

需要做两件事: 一是在字符串表达的数字上模拟加法,二是把字符串表达的数字打印出来。

其中的两个问题分别是:1)如何判断加法溢出而停止;2)如何判断打印出符合习惯的数,不包含首位的0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.util.Arrays;

public class printToMaxOfNDigits1 {

public static void main(String[] args) {
printToMaxOfNDigits1(3);
}

public static void printToMaxOfNDigits1(int n) {
if(n <= 0) {
return;
}
char[] nums = new char[n + 1];
Arrays.fill(nums, '0');
while(!increment(nums)) {
printNum(nums);
}
}

public static boolean increment(char[] nums) {
//这是一个能够判断溢出的
int carry = 0;
for(int i = nums.length - 1; i >= 0; i--) {
// 转换为int
int temp = nums[i] - '0' + carry;
//因为是加1,所以肯定是在最后一位上加1了
if(i == nums.length - 1) {
temp++;
}
// 查看进位
carry = temp / 10;
// 取个位
temp %= 10;
// 转换为字符串
nums[i] = (char)(temp + '0');
}
// 最高位进位为1时则说明溢出了,它实现了用0(1 )时间判断是不是已经到了最大的n位数
return nums[0] == '1';
}

// 打印
public static void printNum(char[] nums) {
int index = 0;
// 除去前面无意义的0
for(; index < nums.length; index++) {
if(nums[index] != '0'){
break;
}
}
for(; index < nums.length; index++) {
// 连续打印
System.out.print(nums[index]);
}
System.out.println();
}

}

递归法全排

n位所有十进制数其实就是n个从0到9 的全排列。

递归结束的条件是我们已经设置了数字的最后一位。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
public class printToMaxOfNDigits2 {

public static void main(String[] args) {
printToMaxOfNDigits2(2);
}

public static void printToMaxOfNDigits2(int n) {
if(n <= 0) {
return;
}
char[] nums = new char[n];
recursiveProductNum(0, n, nums);
}

public static void recursiveProductNum(int index, int length, char[] nums) {
// 填充完所有位后打印
if(index == length) {
printNum(nums);
return;
}
// 每一位从0-9循环
for(char i = '0'; i <= '9'; i++){
// 填充第index位
nums[index] = i;
// 递归填充下一位
recursiveProductNum(index + 1, length, nums);
}
}

public static void printNum(char[] nums) {
int index = 0;
for(; index < nums.length; index++) {
if(nums[index] != '0'){
break;
}
}
for(; index < nums.length; index++) {
System.out.print(nums[index]);
}
System.out.println();
}
}

总结

  1. 字符串是一个简单、有效的表示大数的方法。
  2. 扩展:8 个bit 的char 型字符最多能表示256 个字符,用char 型字符串来表示十进制的数字并没有充分利用内存,有一些浪费。有没有更高效的方式来表示大数?
  3. 进阶题目:以实现任意两个整数的加法。

References

《剑指offer》

剑指Offer-14-打印1到最大的n位数

题目

大学的同学来自全国各地,对于远离家乡步入陌生大学校园的大一新生来说,碰到老乡是多么激动的一件事,于是大家都热衷于问身边的同学是否与自己同乡,来自新疆的小赛尤其热衷。但是大家都不告诉小赛他们来自哪里,只是说与谁是不是同乡,从所给的信息中,你能告诉小赛有多少人确定是她的同乡吗?

image-20200329170401008

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
while 1:
n, m = map(int, input().split())
mates = [i for i in range(n)]
for i in range(m):
a, b, c = map(int, input().split())
if c == 1:
if a < b:
mates[b - 1] = mates[a - 1]
else:
mates[a-1] = mates[b-1]
count = 0
for mate in mates:
if mate == mates[0]:
count += 1
print(count-1)

总结

  1. Python中的Input()函数只能读入一行输入,因为其识别回车符为一次输入的结束。

references

动脑子认老乡

0%