<?php

print_r(twoSum([4,4], 8));
print_r(twoSum([3,2,4], 6));
print_r(twoSum([1,3,4,2], 6));
print_r(twoSum([2,11,7,15], 9));
print_r(twoSum([-1,-2,-3,-4,-5], -8));

function twoSum($nums, $target){
	$cnt=count($nums);
	
	for ($i=0; $i<$cnt-1; $i++){
		for ($j=$i+1; $j<$cnt; $j++){
			
			if ($nums[$i]+$nums[$j]==$target){
				
				return [$i, $j];
			}
		}
	}
	
}
by ვაჟა ტყემალაძე
2 years ago
PHP
Problem Solving
PHP Object Oriented Programming (OOP)
0
Pro tip: use ```triple backticks around text``` to write in code fences