How to make this div element the size of the img contained within it? [css] [migrated]

I am attempting to create a tooltip, to appear when hovering on an image within a table. However when I add the div to put a container for the tooltip, it adds extra spacing to my table, as seen in the first row (not applied to subsequent rows).

Why is the div 118 x 66 size as shown instead of the size of the image within it (59×59 )? It creates unnecessary spacing.

Oversized horitionzal dimension


CSS for tooltip

Tooltip in action

Need help optimizing an algorithm that’s supposed to maximize the greatest common divisor of n elements by removing at most one element

Alright, first here’s the text of the problem:

You’re given n bags of candies where the i-th bag contains a[i] candies and all numbers a[i] are in the segment [1,m]. You can choose a natural number x and each second remove x candies from one of the bags if it contains at least x candies. The goal is to empty all the bags except at most one of them. Find the greatest possible value of x that allows you to achieve this goal.

The desired time complexity is O(n* log m);

What I managed(I think) to do is write an O(n^2 * log m) algorithm (the two nested for loops are O(n^2) and Euclid’s algorithm is O(log m)).

The code written in c++ is below. The second for loop calculates the gcd of the numbers excluding the i-th number and I calculate the maximum by considering all values of i, but apparently it can be done linearly. Any ideas on how to optimize it to O(n* log m)?

int gcd(int a, int b){     if(b == 0)         return a;     return gcd(b, a%b); }   int greatestPossibleGcd(int *arr, int n){     int maxgcd = 0;     int current = 0;      for(int i=0;i<n;i++){         maxgcd = gcd(maxgcd, arr[i]);     }      for(int i=0;i<n;i++){         for(int j=0;j<n;j++){             if(j == i)                 continue;             current = gcd(current, arr[j]);         }         if(current > maxgcd)             maxgcd = current;          current = 0;     }      return maxgcd;  } 

Improving QuickSort Algorithm with pivot as first element

I was trying to improve the algorithm since its the most effective and known algorithm among many others, I came across ” Quicksort algorithm with an early exit for sorted subfiles 1987 by University of Tulsa, Roger L. Waiwright” check it out its interesting, do you guys know any other ways/researches ? I think reducing the memory would work by reducing the amount of arrays and working on one array idk how I am going to do that.

doing bubble sort or selection sort for large arrays isn’t helpful and checking if a big array is sorted using them would increase the complexity. P.S: I am just learning and studying not doing a research etc.

Quicksort algorithm with an early exit for sorted subfiles

Generate slice that contains element

Suppose I have the array:

[2, 3, 4, 5, 6, 7, 8, 9] 

Now based on few parameters:

  1. current_item – currently selected item.
  2. select_size – selection size, always odd.

I want to get a sublist of the list that follows the conditions:

  1. current_item should be in middle of sublist if that is possible.
  2. In case when there is not enough elements on left/right of the list, use the ones from right/left.


list: [2, 3, 4, 5, 6, 7, 8, 9] current_item: 5 select_size: 3  result: [4, 5, 6]   list: [2, 3, 4, 5, 6, 7, 8, 9] current_item: 2 select_size: 5  result: [2, 3, 4, 5, 6]  list: [2, 3, 4, 5, 6, 7, 8, 9] current_item: 8 select_size: 5  result: [5, 6, 7, 8, 9] 

Finding sequence of pairs with second element of previous pair matching first element of next pair

I am interested in efficient ways of doing certain problem.

I have list of $ n$ pairs, where $ n$ is usually a few houndred thousands and each pair’s element is an integer (let’s assume it is integer from $ 0$ to $ 10000$ ) and I am trying to find a sequence such that it start and ends at chosen integer (we can assume it is eg. $ 0$ ) and second element of previous pair matches first element of next pair. So as an example, if we have set of pairs $ \{(0,1), (1,3), (3, 2) (3,0)\}$ the valid sequence would be eg. $ (0,1), (1,3), (3, 0)$ . If there is a few answers then I can find arbitrary one. Moreover it is no certain that my list of pairs actually has a solution. If it does not have solution, then the method should return no valid solutions.

I think that maybe some kind of dynamic programming could be useful here, but I don’t really have an idea for something better than just checking all the options, which I am almost certain is quite bad. Do you have any interesting insight about this problem?

Purpose of Secure Element

What is the purpose of embedding a Secure Element to enhance the security – especially the storage of keys- if a key is required to connect with it in order to get its secrets?

For example: Let’s suppose I have a host that is not secure enough to store keys in its ROM. I will hence store keys in a remote Secure Element that will be connected to my host. However, it would hence be required to secure the communication with the Secure Element to keep the confidentiality of the informations shared between the host and the Secure Element, such as the keys.

Now here’s the problem: how should I store the secret to connect with the SE (symmetric Secret key or Certificate), if storing the keys was the exact reason of integrating a Secure Element ?

It seems like a chicken and the egg problem…

How to disabel relro to overwrite fini_array element?

I am reading the book Hacking: The art of exploitation and there is a format string exploit example which attempts to overwrite an address of the dtors with the address of a shellcode environment variable. I work on Kali Linux 64-bit and already found out that there is not dtors and so now I try to overwrite the fini_array. I already verified that the exploit writes the right address to the address given but when I run it with the address of fini_array I get a SIGSEV. After reading this I think the problem is that the partial relro won’t let me overwrite fini_array. Now my question is which workaround (maybe some gcc options) I could use to solve my problem.