LeetCode题解(十一)1000-1099

sb.append©;

} else {

numR++;

if (numL == numR) {

numL = 0;

numR = 0;

} else {

sb.append©;

}

}

}

return sb.toString();

}

}

Runtime: 19 ms, faster than 16.37% of Java online submissions for Remove Outermost Parentheses.

Memory Usage: 37 MB, less than 94.16% of Java online submissions for Remove Outermost Parentheses.

class Solution {

public String removeOuterParentheses(String S) {

String result = “”;

int open = 0;

for (char c : S.toCharArray()) {

if (c == ‘(’) {

if (open > 0) {

result += “(”;

}

open++;

} else {

if (open > 1) {

result += “)”;

}

open–;

}

}

return result;

}

}

1051. Height Checker

[Description]

Students are asked to stand in non-decreasing order of heights for an annual photo.

Return the minimum number of students not standing in the right positions. (This is the number of students that must move in order for all students to be standing in non-decreasing order of height.)

Example 1:

Input: [1,1,4,2,1,3]

Output: 3

Explanation: Students with heights 4, 3 and the last 1 are not standing in the right positions.

Note:

1 <= heights.length <= 100

1 <= heights[i] <= 100

[Answer]

Runtime: 1 ms, faster than 94.99% of Java online submissions for Height Checker.

Memory Usage: 34.7 MB, less than 100.00% of Java online submissions for Height Checker.

class Solution {

public int heightChecker(int[] heights) {

int[] raw = new int[heights.length];

raw = heights.clone();

Arrays.sort(heights);

int diff = 0;

for (int i = 0; i < heights.length; i++) {

if (raw[i] != heights[i])

diff++;

}

return diff;

}

}

1078. Occurrences After Bigram

[Description]

Given words first and second, consider occurrences in some text of the form “first second third”, where second comes immediately after first, and third comes immediately after second.

For each such occurrence, add “third” to the answer, and return the answer.

Example 1:

Input: text = “alice is a good girl she is a good student”, first = “a”, second = “good”

Output: [“girl”,“student”]

Example 2:

Input: text = “we will we will rock you”, first = “we”, second = “will”

Output: [“we”,“rock”]

Note:

1 <= text.length <= 1000

text consists of space separated words, where each word consists of lowercase English letters.

1 <= first.length, second.length <= 10

first and second consist of lowercase English letters.

[Answer]

Runtime: 1 ms, faster than 95.34% of Java online submissions for Occurrences After Bigram.

Memory Usage: 34.9 MB, less than 100.00% of Java online submissions for Occurrences After Bigram.

class Solution {

public String[] findOcurrences(String text, String first, String second) {

String[] textA = text.split(" ");

ArrayList result = new ArrayList<>();

for (int i = 0; i < textA.length - 2; i++) {

if (textA[i].equals(first) && textA[i + 1].equals(second))

result.add(textA[i + 2]);

}

String[] res = new String[result.size()];

for (int i = 0; i < result.size(); i++) {

res[i] = (String) result.get(i);

}

return res;
}
}

最后

简历首选内推方式,速度快,效率高啊!然后可以在拉钩,boss,脉脉,大街上看看。简历上写道熟悉什么技术就一定要去熟悉它,不然被问到不会很尴尬!做过什么项目,即使项目体量不大,但也一定要熟悉实现原理!不是你负责的部分,也可以看看同事是怎么实现的,换你来做你会怎么做?做过什么,会什么是广度问题,取决于项目内容。但做过什么,达到怎样一个境界,这是深度问题,和个人学习能力和解决问题的态度有关了。大公司看深度,小公司看广度。大公司面试你会的,小公司面试他们用到的你会不会,也就是岗位匹配度。

面试过程一定要有礼貌!即使你觉得面试官不尊重你,经常打断你的讲解,或者你觉得他不如你,问的问题缺乏专业水平,你也一定要尊重他,谁叫现在是他选择你,等你拿到offer后就是你选择他了。

另外,描述问题一定要慢!不要一下子讲一大堆,慢显得你沉稳、自信,而且你还有时间反应思路接下来怎么讲更好。现在开发过多依赖ide,所以会有个弊端,当我们在面试讲解很容易不知道某个方法怎么读,这是一个硬伤…所以一定要对常见的关键性的类名、方法名、关键字读准,有些面试官不耐烦会说“你到底说的是哪个?”这时我们会容易乱了阵脚。正确的发音+沉稳的描述+好听的嗓音决对是一个加分项!

最重要的是心态!心态!心态!重要事情说三遍!面试时间很短,在短时间内对方要摸清你的底子还是比较不现实的,所以,有时也是看眼缘,这还是个看脸的时代。

希望大家都能找到合适自己满意的工作!

进阶学习视频

附上:我们之前因为秋招收集的二十套一二线互联网公司Android面试真题 (含BAT、小米、华为、美团、滴滴)和我自己整理Android复习笔记(包含Android基础知识点、Android扩展知识点、Android源码解析、设计模式汇总、Gradle知识点、常见算法题汇总。)


《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》点击传送门,即可获取!
公司Android面试真题** (含BAT、小米、华为、美团、滴滴)和我自己整理Android复习笔记(包含Android基础知识点、Android扩展知识点、Android源码解析、设计模式汇总、Gradle知识点、常见算法题汇总。)

[外链图片转存中…(img-0hDDcdWo-1715674220804)]
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》点击传送门,即可获取!

  • 30
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值