This solution to the problem presented on :     Given an array of integers, find two numbers such that they add up to   a specific target number.      The function twoSum should return indices of the two numbers such that   they add up to the target, where index1 must be less than index2.   Please note that your returned answers (both index1 and index2) are   not zero-based.      You may assume that each input would have exactly one solution.      Input: numbers={2, 7, 11, 15}, target=9 Output: index1=1, index2=2   by wz2326 ():  vector&lt;int&gt; twoSum(vector&lt;int&gt;&amp; nums, int target) {     unordered_map&lt;int, int&gt; hash;     vector&lt;int&gt; res(2, 0);     for (int i = 0; i &lt; nums.size(); i++) {         if (hash.find(target - nums[i]) != hash.end()) {             res[0] = hash[target - nums[i]], res[1] = i + 1;             return res;         }         hash[nums[i]] = i + 1;     } }   introduces pretty strange use of commas during assignment of int values to vector elements:  res[0] = hash[target - nums[i]], res[1] = i + 1;   Does anyone know the meaning of comma here? Thanks.
How does the comma operator work in C++?  For instance, if I do:  a = b, c;     Does a end up equaling b or c?   (Yes, I know this is easy to test - just documenting on here for someone to find the answer quickly.)  Update:  This question has exposed a nuance when using the comma operator.  Just to document this:  a = b, c;    // a is set to the value of b!  a = (b, c);  // a is set to the value of c!   This question was actually inspired by a typo in code.  What was intended to be  a = b; c = d;   Turned into  a = b,    //  &lt;-  Note comma typo! c = d;
How to "shuffle" an array? Package in Java Can I create a Controller that simply returns an image asset?  I would like to route this logic through a controller, whenever a URL such as the following is requested:  www.mywebsite.com/resource/image/topbanner   The controller will look up topbanner.png and send that image directly back to the client.  I've seen examples of this where you have to create a View - I don't want to use a View. I want to do it all with just the Controller.  Is this possible? For all $a, m, n \in \mathbb{Z}^+$,   $$\gcd(a^n - 1, a^m - 1) = a^{\gcd(n, m)} - 1$$ I dual booted ubuntu 11.04/11.10 a while ago with a USB stick and i want to uninstall it.   I would like to completely uninstall the old version and get 12.04.  I have a 64 bit laptop. Please help! How do I avoid the "S to Skip" message on boot? After upgrading my laptop from karmic to lucid, my fat32 partition won't mount automatically. I get the message:  The disk drive for /osshare is not ready yet or not present Continue to wait; or Press S to skip mounting or M for manual recovery   Funny thing is, if I skip, then /osshare/ is mounted once I log in.   I've a similar setup on my desktop, and it works fine. Fstab on desktop:  UUID=4663-6853  /osshare        vfat    utf8,umask=007,gid=46 0       1   /etc/fstab on laptop:  UUID=1234-5678 /osshare vfat utf8,auto,rw,user 0 0 My Linux Mint 15 install on VirtualBox was working great up until about two days ago, when the updater started throwing a ton of errors and refuses to progress with any apt-get update, apt-get install, or apt-get upgrade.  They are 404 errors on the archive.ubuntu.com site, under the /ubuntu/dists/raring-updates folder. I looked at it, it doesn't exist.  a direct link, which shows there is no raring-updates.  Where has raring-updates gone and what can I do to fix this? Maximum value of $\sin A+\sin B+\sin C$? Easiest way to move my Windows installation to an SSD? I've taken the plunge and bought an SSD and want to move my existing Windows installation over. The current hard disk is 500Gb, but I've trimmed the contents down to about ~40Gb. I'm transferring it across to a 100Gb SSD and looking for the easiest way just to copy everything across and set the SSD up as a boot device.  I've looked at a few tools like Macrium Reflect, but they don't seem able to restore to a smaller drive. Do I need to go for something like  to do this? I'm trying to avoid scary Linux-based boot utilities if possible, does anyone know of an easier way? Keyboard layout indicator sometimes disappears Ubuntu 18.04.1 after some update ViewExpiredException in Firefox and IE after migrating to Jboss 7.0 AS How can I prevent Windows from prompting to restart my computer after an update? Let $P\in\mathbb{R}[X]$ be a positive polynomial.  I want to show that there exists $A,B\in\mathbb{R}[X]$ so that $P=A^2+B^2$    $\displaystyle P=a\prod_{k=0}^q(x-a_k)\prod_{k=0}^{2p}(x-b_k)=a\prod_{k=0}^q(x-a_k)\prod_{k=0}^p(x^2-2\Re(b_k)+|b_k|^2)$ where $a$ is the leading coefficient, $a_k$ are the real rooks, $b_k$ are the complex roots.  What can i do now ? I know that the identity $(a^2+b^2)(c^2+d^2)=(ac-bd)^2+(ad+bc)^2$ should come in handy, but I can't figure out :  1) How to show that the product real roots is a square  2) How to use the above identity for the complex roots.  If I can solve those two points, then I can solve the problem. Use of inequality $1 - \cos (x) \leq x^2 /2$ In  answer the value of $1 - \cos(x)$ has to be evaluated in order to find its upper limit, if it exists.  In particular, $x = 2 \pi / n$. The answer is related to the length of a side of a regular $n$-gon inscribed into a unit-radius circumference; because the perimeter of the $n$-gon is always less than $2 \pi$, the single side must always be less than $2 \pi / n$.  The inequality  $$1 - \cos (x) \leq \displaystyle \frac{x^2}{2}$$ (1)  is used and the proof is completed with   $$2(1 - \cos(x)) \leq (2 \pi / n)^2$$  $$\sqrt{2(1 - \cos(x))} \leq 2 \pi / n$$  But it is well known that the cosine is a function $f(x) \in [-1;1]$, so $1 - \cos (x) \in [0,2]$. By using this information, we would obtain  $$1 - \cos (x) \leq 2$$ (2)  The proof would provide  $$2(1 - \cos(x)) \leq 4$$  $$\sqrt{2(1 - \cos(x))} \leq 2$$  which is a completely different result.   Why in that case it is preferable to use (1) instead of (2)? How to choose when it is convenient to use (1) and when to use (2) in a proof? zero matrix to the power of 0 Why $0^0=I$?   I'd tried prove that considering $N^0$ where N is a Nilpotent matrix and then using the Cayley -Hamilton theorem  Thanks in advance. Most of the time, I use good and well interchangeably. However, on many occasions I would find well or good a misfit. Please suggest the proper usage. Volume control on asus zenbook 3 Using Ubuntu 16 LTS  I installed ubuntu on my new asus zenbook3 ux390. Nearly everything works fine except the volume controls don't work. The volume is either on or off. I can adjust volume in specific apps or websites (like youtube) successfully, but the internal volume control either wants to be muted or at 100%. Universe being flat and why we can't see or access the space "behind" our universe plane? I'm a layman, but i watched some intereting videos about big bang on youtube[michio kaku, hawking this kind of things, not some crackpots :)]   I described everything on my picture:     So is there any possibility to see that inner side, for example, by creating wormhole, or entering new dimension? Or i get something wrong, on the way, and my model is totally wrong?  And another question. I heard that even if you would fly a ship across the universe you would eventually end in the place where you started, because we live in a 3d space that is defined on a surface of big sphere. But why a big sphere? Universe might be a big mobius strip, and the same principle of ending at start will apply. Is it possible?  Thanks in advance, and please don't bash me for silly questions. Im just curious, but i don't have any degree in physics. Im also not an english native speaker. I found  where a technician with a lot of experience seems to clean his PCBs using water, and then he just puts it in the sun so it can dry. I was just amazed to see the circuit keeps working as intended, he says he keeps doing this all the time and several times, however I doubt this is normal.  Which leave me some questions:   What are the recommended methods to clean huge PCBs like the one in the video? What happens to charged capacitors when water shorts them out? Solder joints do not get any kind of corrosion? Is the antisolder mask waterproof? How do you set, clear, and toggle a single bit? How do you set, clear, and toggle a bit?