leetcode問題ライブラリ:1.両数の和


整数配列とターゲット値を指定し、配列とターゲット値の2つの数を見つけます.
入力ごとに1つの答えしか対応せず、同じ要素が再利用できないと仮定できます.
例:
   nums = [2, 7, 11, 15], target = 9
   nums[0] + nums[1] = 2 + 7 = 9
     [0, 1]
私の答え:
/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* twoSum(int* nums, int numsSize, int target) {
    int i,j,sum=-1,io,jo,flag=0;
    for(i=0;ijo?io:jo;
    return out;
}
コード実行結果:
マイ入力
[2,7,11,15]
9
私の答え
[0,1]
予想される答え
[0,1]