Test 13 goes wrong


  • 0
    H

    my java code went wrong with the 13th test, and i don't know why.Can anyone help me.
    public class Solution {
    public int[] twoSum(int[] nums, int target) {
    int b=0,c=0;

            for(int i=0;i<nums.length;i++){
    	        	for(int k=0;k<nums.length;k++){
    	        		if(k!=i){
    		        		if((nums[i]+nums[k])==target){
    		        				c=k;
    			        			break;
    			        		}
    	        		}
    	        	}
            	if(c!=0){
            		b=i;
            		break;
            	}
            	i++;
            }
            int[] a={b,c};
            return a;
        }
    

    }


  • 0
    Q

    @hyp123654
    i++ write twice.only write once


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.