题目
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
1 | Example 1: |
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
1 | Example 1: |
Given an array nums and a value val, remove all instances of that value in-place and return the new length.
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
The order of elements can be changed. It doesn’t matter what you leave beyond the new length.
Merge two sorted linked lists and return it as a sorted list. The list should be made by splicing together the nodes of the first two lists.
1 | Example 1: |
《武林高手在校园》这本穿越小说我高中&大学时读了很多遍,也算是我读的第一本穿越小说,有一处印象比较深的情节,在此记录并抒发一下自己的感受。
内容应该在73-74节之间,当时油老鼠和林逸飞在街上走着,突然碰到一个人骑自行车钱包掉了出来,立马有人过来说见者有份,要平分赃款,而林逸飞早已识破骗局,于是油老鼠也跟着走了,并说了一句“可恶的河南人”,而林逸飞就说出了我印象最深的话: 林逸飞叹息道:“哪个地方都有好人,都会有骗子,你这么一棒子把人打死,难道不嫌太武断了吗?”
为什么我会对这句话印象极其深刻呢?——因为我见过太多的地域歧视。
上大学那会,我的本科舍友们偶尔会在宿舍关灯后还是唠嗑,这时候我就会闭嘴,因为话题真的很无语,比如——他们一直认为四川人的个子都很矮(我只想说如果都很矮那难道像CBA这种篮球比赛四川队都垫底吗?);偷井盖子的都是河南人;广东人做的东西不要吃;….等等这种带着地域的偏见。
然而,当我毕业后,在成都拿了一家互联网公司的offer后,我发现四川当地人并不矮,地铁上、公交车上到处都是高个子;我在部门认识的河南同事都非常乐于助人,有时会停下手里的活帮我来看代码问题;广东的肠粉路边摊到处都是…所以,我学会了怀疑别人说的话,同时也建立了一个前提:哪个地方都有好人,都会有骗子,不能因为这地方出现了这件事情,就把这个地方的人一棍子打死。
Write a function to find the longest common prefix string amongst an array of strings.
If there is no common prefix, return an empty string “”.
1 | Example 1: |
先维护一个map
,用于建立罗马数字和整数的关系,接着挨个破译即可。
1 | //Go |