我在数据结构类的以下作业问题上呆了几个小时:
从{1,。。得到n个整数的静态集合S(即S永不改变)。。。,u}。
描述大小为O(n log u)的数据结构,该数据结构可以在O(1)时间内回答以下查询:
Empty(i, j)-当且仅当S中没有元素介于i和j之间(其中i和j是{1,...,u}中的整数)时,-才返回TRUE。
起初,我想到了使用y-fast-trie。
使用y-fast-trie我们可以实现O(n)空间和O(loglogu)查询(通过找到i的后继者并检查它是否大于j)。
但是O(loglogu)不是O(1)...
然后,我想也许我们可以对数组进行排序,并创建第二个大小为n + 1的范围的数组,该范围不在数组中,然后在查询中检查[i,j]是否为以下项之一的子范围范围,但我没有想到使用O(nlogu)空间并且可以在O(1)中回答查询的任何方法。
我不知道如何解决这个问题,而且我觉得我甚至还没有找到解决方案,任何帮助都很好。
我有两列,都是屏幕宽度的50%.左列填充文本,右列填充图像,缩放到文本的高度.另一幅图像放在第一张图像上,位于右下角.即使屏幕宽度超出图像宽度(并且图像右侧出现空白),第二个图像也应保持与第一个图像的右下角保持对齐.
您可以在下面的代码中看到的设置适用于除Firefox以外的浏览器.在Firefox中,第二个图像尽可能位于最右侧,直到第一个图像的原始宽度.我想我已经将它缩小到我给出的100%高度.image div,如果我使用固定高度(即400px),则第二个图像正确对齐.我需要百分比高度,让第一个图像缩放到文本高度.
.wrapper {
overflow: hidden;
position: relative;
}
.text {
width: 50%;
position: relative;
}
.image {
width: 50%;
position: absolute;
left: 50%;
top: 0;
bottom: 0;
}
.image div {
position: relative;
display: inline-block;
vertical-align: top;
height: 100%;
max-width: 100%;
overflow: hidden;
}
.image div:after {
content: url("https://vignette1.wikia.nocookie.net/uncyclopedia/images/6/67/Marvin_the_martian.jpg");
display: block;
position: absolute;
bottom: 0;
right: 0;
width: 100px;
height: 120px;
}
.image>div>img {
display: block;
height: 100%;
width: auto;
}Run Code Online (Sandbox Code Playgroud)
<div class="wrapper">
<div class="text">
<p> …Run Code Online (Sandbox Code Playgroud)我正在尝试替换int^with的每个子字符串<int>^.
例如:如果我有字符串,"aaa500^bbb"我想得到字符串"aaa<500>^bbb"