In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "js array continuous screening processing method is what", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "js array continuous filtering processing method is what" it!
Algorithm interview questions:
There is an array [1, 1, 2, 3, 4, 5, 5, 8, 10, 22, 24, 25, 26, 66]. Please write a way to turn the array into [1, 1, 2, 3, 4, 5], 8, 10, 22, [24, 25, 26], 66].
The general idea is loop traversal, each traversal to determine whether the difference between the current item and the previous item is 1, here we need to consider if the result is 1, how to deal with, the result is not 1 how to deal with.
The result is not 1, we can insert the current item directly into the result array, but here we need to consider the boundary problem, we set two variables, the first variable array length len, the second variable array traversal start position I, for convenience, we set I to 1.
The code is as follows:
Var len = arr.length
Var res = []
For (var I = 1; I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.