当前位置:网站首页>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
边栏推荐
- Live HLS protocol
- Ffmpeg common commands (2)
- ffmpeg 错误码
- mysql 報錯 Can‘t create table ‘demo01.tb_Student‘ (errno: 150)*
- 为什么一定要从DevOps走向BizDevOps?
- Thesis reading [distinctive late semantic graph for video capturing]
- JVM memory model
- 1592 例题1 国王(Sgu223 LOJ10170 LUOGU1896 提高+/省选-) 暴力思考 状压DP 01背包
- Axure does not display catalogs
- Proxy in ES6
猜你喜欢
![[Mori city] random talk on GIS data (I)](/img/4d/1ed4bbf397b8d756c91241705528de.jpg)
[Mori city] random talk on GIS data (I)

再回顾集合容器

wireshark报文分析tcp,ftp

optaplanner学习笔记(一)案例Cloud balance

DTD modeling

Salesmartly has some tricks for Facebook chat!

Why has instagram changed from a content sharing platform to a marketing tool? How do independent sellers use this tool?

HLS4ML报错The board_part definition was not found for tul.com.tw:pynq-z2:part0:1.0.

Basic use of MySQL

The key to the success of digital transformation enterprises is to create value with data
随机推荐
Time series analysis using kibana timelion
【无标题】
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
2022/6/8-2022/6/12
Remove line breaks from MySQL query results
Simplified pinduoduo product data
Define dichotomy lookup
optaplanner学习笔记(一)案例Cloud balance
Crunch简介、安装,使用Crunch制作密码字典
[research materials] national second-hand housing market monthly report January 2022 - Download attached
OpenCV视频质量诊断----视频遮挡诊断
New window open page -window open
Thesis reading [distinctive late semantic graph for video capturing]
Basic knowledge of audio coding and decoding
703. The k-th element in the data flow
【AI服务器搭建】CUDA环境
安装sharp报错
Analysis of GetMessage underlying mechanism
Anaconda安装虚拟环境到指定路径
HLS4ML进入方法