Interview Question 4Sum

Last update: 1/1/2017 11:49:00 PM

By Fatih KABAKCI

The problem is to find out all unique quadruplets in the array which the sum of any 4 elements is a specified target. The solution of the problem is almost same with the solution of the problem 3Sum. The only difference between them is number of the elements in the list which have been gathered, and the target does not have to be zero as 3Sum does. However, by this way, it is similar to solution of the problem 3Sum Closest..

So, in order to understand this problem, it is better idea to understand 3Sum Problem.

Problem #18 - 4Sum

Description: Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.

A programming language is a formal constructed language designed to communicate instructions to a machine, particularly a computer. It can be used to create programs to control the behavior of a machine.
Java,C,
C++,C#

Computer hardware is the collection of physical elements that constitutes a computer system. Computer hardware refers to the physical parts or components of a computer such as the monitor, memory, cpu.

Web development is a broad term for the work involved in developing a web site for the Internet or an intranet. Html,Css,JavaScript,ASP.Net,PHP are one of the most popular technologies.
J2EE,Servlet,
JSP,JSF,
ASP

Mobile application development is the process by which application software is developed for low-power handheld devices, such as personal digital assistants, enterprise digital assistants or mobile phones.
J2ME

A computer network or data network is a telecommunications network that allows computers to exchange data. In computer networks, networked computing devices pass data to each other along data connections.

An operating system is software that manages computer hardware and software resources and provides common services for computer programs. The OS is an essential component of the system software in a computer system.
Linux,Windows