当前位置:网站首页>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
边栏推荐
- mysql 報錯 Can‘t create table ‘demo01.tb_Student‘ (errno: 150)*
- IPv4 address, subnet mask, gateway
- 墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路
- P2433 【深基1-2】小学数学 N 合一
- How to configure webrtc video streaming format for easygbs, a new version of national standard gb28181 video platform?
- DDR4 test-2
- Anaconda安装虚拟环境到指定路径
- Image acquisition and playback of coaxpress high speed camera based on pxie interface
- 一个程序员如何快速成长
- GC garbage collection
猜你喜欢

MySQl的基本使用

Shell高级进阶
![[research materials] national second-hand housing market monthly report January 2022 - Download attached](/img/c8/a205ddc2835c87efa38808cf31f59e.jpg)
[research materials] national second-hand housing market monthly report January 2022 - Download attached
![Thesis reading [distinctive late semantic graph for video capturing]](/img/d4/4f84a73a9127fa87bb0a74c4655d15.png)
Thesis reading [distinctive late semantic graph for video capturing]
![[research materials] Huawei Technology ICT 2021: at the beginning of the](/img/83/f21f148103815691796f87a95c687f.jpg)
[research materials] Huawei Technology ICT 2021: at the beginning of the "Yuan" year, the industry is "new" -- download attached
![[research materials] iResearch tide Watching: seven major trends in the clothing industry - Download attached](/img/c8/a205ddc2835c87efa38808cf31f59e.jpg)
[research materials] iResearch tide Watching: seven major trends in the clothing industry - Download attached

对象的创建

振弦采集模块测量振弦传感器的流程步骤
![[research data] observation on the differences of health preservation concepts among people in 2022 - Download attached](/img/50/926cc5bce83f8b195b3e2072b656bf.jpg)
[research data] observation on the differences of health preservation concepts among people in 2022 - Download attached
![P2433 [deep foundation 1-2] primary school mathematics n in one](/img/28/e5eab8927694ea002b536202a1b5ea.png)
P2433 [deep foundation 1-2] primary school mathematics n in one
随机推荐
[AI server setup] CUDA environment
JS的Proxy
Actual combat of flutter - fast implementation of audio and video call application
Regular expression =regex=regular expression
【AI服务器搭建】CUDA环境
Ffmpeg common commands (2)
wireshark报文分析tcp,ftp
Cookie和Session的相关概念
Mysql查询结果去除换行
ffmpeg 错误码
How to correctly use vertx to operate redis (3.9.4 with source code analysis)
ES6中的代理proxy
uni-app微信小程序一键登录获取权限功能
Wireshark packet analysis TCP, FTP
Mo Tianlun salon | Tsinghua qiaojialin: Apache iotdb, originated from Tsinghua, builds an open source ecological road
optaplanner学习笔记(一)案例Cloud balance
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
H264编码profile & level控制
ffmpeg常用命令(二)
118. 杨辉三角