Return True if array contains a 2 or a 3

后端 未结 4 1818
南笙
南笙 2021-01-20 15:01

I\'m having trouble with this CodingBat problem:

Given an int array length 2, return True if it contains a 2 or a 3.

I\'ve trie

4条回答
  •  迷失自我
    2021-01-20 15:15

    This Java code works fine:-

    public boolean has23(int[] nums) {
      if(nums[0]==2||nums[1]==2||nums[0]==3||nums[1]==3){
        return true;
      }
      return false;
    }
    

提交回复
热议问题