当前位置:网站首页>Interview questions shared in today's group
Interview questions shared in today's group
2022-07-01 19:46:00 【Wang yuanrou】
List of articles
As usual , Click on the learning exchange group before going to bed , Today, there was no fishing in the Group , Discussing interview questions , It immediately brought up my interest , Crouched for a while , I sent three interview questions , I tried it .
1
topic
My solution
let arr = [4, 5, 5, 3, 2, 8, 7];
let arr2 = [60, 90, 80, 110, 120, 90, 100, 90, 100, 100];
const fn = function(arr) {
let min = arr[arr.length - 1];
let result = [];
arr.reverse().forEach((item, index) => {
if (item <= min) {
min = item;
result.push(arr.length - 1 - index);
}
});
return result.reverse();
};
console.log(fn(arr));
console.log(fn(arr2));
2.
topic
My solution
const arr = [1, 2, 3, 4, 1, 2];
const obj2 = {
value: 0,
child: [],
};
const fn = function(arr, obj) {
if (arr.length >= 2) {
obj.child.push({
value: arr[0], child: [] });
obj.child.push({
value: arr[1], child: [] });
fn(arr.slice(2, arr.length), obj.child[0]);
fn(arr.slice(3, arr.length), obj.child[1]);
} else if (arr.length === 1) {
obj.child.push({
value: arr[0], child: [] });
fn(arr.slice(2, arr.length), obj.child[0]);
}
};
fn(arr, obj2);
console.log(obj2);
const arr2 = [];
const fn2 = function(obj2, sum) {
sum = sum + obj2.value;
if (obj2.child.length === 1) {
fn2(obj2.child[0], sum);
} else if (obj2.child.length === 2) {
fn2(obj2.child[0], sum);
fn2(obj2.child[1], sum);
} else {
arr2.push(sum);
}
};
fn2(obj2, 0);
console.log(arr2.sort()[arr2.length - 1]);
3.
topic
My thoughts
When you give me this question , What I think of is the public longest substring in the query string
So as to get the start coordinate or end coordinate of the modified content
And then intercept it 0 A string from the start coordinate or the end coordinate to the maximum length of the string
Query the public longest substring again
In this way, you can get the start and end coordinates of the modified content
Then cut this paragraph out to be the content you modified
Code implementation follow-up
边栏推荐
- 博途V16 获取系统时间转换成字符串
- [AI server setup] CUDA environment
- 自定义插入页面标签以及实现类似通讯录的首字母搜索
- Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
- mysql 报错 Can‘t create table ‘demo01.tb_Student‘ (errno: 150)*
- Class loading mechanism
- GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
- 【无标题】
- 类加载机制
- Uni app wechat applet one click login to obtain permission function
猜你喜欢
JVM memory model
Mo Tianlun salon | Tsinghua qiaojialin: Apache iotdb, originated from Tsinghua, builds an open source ecological road
Optaplanner learning notes (I) case cloud balance
P2433 【深基1-2】小学数学 N 合一
wireshark报文分析tcp,ftp
MySQl的基本使用
振弦采集模塊測量振弦傳感器的流程步驟
[research materials] Huawei Technology ICT 2021: at the beginning of the "Yuan" year, the industry is "new" -- download attached
After studying 11 kinds of real-time chat software, I found that they all have these functions
解决VSCode下载慢或下载失败的问题
随机推荐
OpenCV视频质量检测--清晰度检测
GB28181之SIP协议
今日群里分享的面试题
OpenCV视频质量诊断----视频遮挡诊断
集合对象值改变NULL值对象
Optaplanner learning notes (I) case cloud balance
The key to the success of digital transformation enterprises is to create value with data
GC垃圾回收
MySQL signale une erreur can 't create table' demo01. TB Étudiant '(errno: 150)
SIP protocol of gb28181
Flutter 实战-快速实现音视频通话应用
Oracle物理体系结构
自定义插入页面标签以及实现类似通讯录的首字母搜索
Process steps of vibrating wire acquisition module for measuring vibrating wire sensor
实例讲解将Graph Explorer搬上JupyterLab
Transaction isolation level gap lock deadlock
音视频、编解码相关电子书、小工具,打包奉送!
GB28181的NAT穿透
How to add transactions in JDBC
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results