Redian新闻
>
Q:实现上一个, 下一个, 产品功能
avatar
Q:实现上一个, 下一个, 产品功能# JobHunting - 待字闺中
l*r
1
一个产品网站,假设所有产品有一个顺序。
随机到一个产品页面, 要求同时显示它的前K个和后K个产品。
要求效率高的。
有没有好办法?
我的笨办法是:
1) assume we get the current page's product.
2) query all products (per the question, they will be sorted in order)
3) find where is the current product in this sorted list. Then it is easy to
take the K ones before and after it.
4) of course some edge conditions will be: k is too big, or current product
is too close to the start / end already (or it is first / last one already).
PS: assume you can use a general backend database (like, MS SQL, Oracle,
MySQL) to save all the product information.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。