对子阵列的查询是否相等 [英] Query on subarray are equal or not

查看:67
本文介绍了对子阵列的查询是否相等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们给出n个整数和Q查询的数组,在每个查询中我们给出2个范围,即

We are given array of n integers and Q queries , in each query we are given 2 ranges, ie

The queries are given as "a b c d" where a and b are the left and right end point of the first sub-array and c and d are the left and right end point of the second sub-array.

我们需要查找两个子数组是否相等?



如果子阵列大小相等,则子阵列相等,排序后所有索引的所有值都相互匹配?

查询数< = 10 ^ 5

数组大小< = 10 ^ 5



示例:

we need to find whether two subarrays are equal or not?

Subarray are equal if their size is equal and after sorting it all the values at all indices matches with each other ?
Number of queries <= 10^5
Size of array <= 10^5

Example:

TestCase:
6 3 // n and q
1 3 4 2 3 4 // array elements
1 3 4 6 // queries
1 2 5 6
3 5 2 4

Output:
YES
NO
YES





我尝试了什么:



我试过许多事情,但它给我TLE和它的复杂性并不好



What I have tried:

I have tried with many things but its giving me TLE ans its complexity is not good

推荐答案

帮自己一个忙,停止做那些挑战。

所有什么你学到的是你无法足够快地完成它们。

为了应对这些挑战,你需要学习高级算法(并理解它们),它不仅仅是少数几个,还有几十个其中,你需要学习将它们结合起来以获得最佳解决方案的艺术。

当你学习算法时,你会发现你还需要掌握数据结构。

所有那些适合书籍和t在这个论坛的框架中我们无法告诉你。

Do yourself a favor and stop doing those challenges.
All what you learn is that you are unable to complete them fast enough.
To compete on those challenges, you need to learn advanced algorithms (and understand them), and it is not just a few, there are tens of them, and you need to learn the art of combining them to get an optimum solution.
As you learn algorithms, you will see that you also need to master data structures.
All those fit in books and there is no way we can teach them to you in the frame of this forum.
引用:

我试过了有很多东西,但它给我TLE和它的复杂性不好

I have tried with many things but its giving me TLE ans its complexity is not good



你没有向我们展示你的工作,你甚至没有问过一个问题。


You have shown us nothing of your work, you did not even asked a question.

这篇关于对子阵列的查询是否相等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆