zoukankan      html  css  js  c++  java
  • LeetCode: Single Number

    简单题

     1 class Solution {
     2 public:
     3     int singleNumber(int A[], int n) {
     4         // IMPORTANT: Please reset any member data you declared, as
     5         // the same Solution instance will be reused for each test case.
     6         int ans = 0;
     7         for (int i = 0; i < n; i++) ans ^= A[i];
     8         return ans;
     9     }
    10 };

     C#

    1 public class Solution {
    2     public int SingleNumber(int[] nums) {
    3         int ans = 0;
    4         for (int i = 0; i < nums.Length; i++) ans ^= nums[i];
    5         return ans;
    6     }
    7 }
    View Code
  • 相关阅读:
    JSTL和EL
    JSP
    Servlet基础知识
    JSON基础知识
    jQuery基础知识
    ajax基础知识
    索引实战
    反射
    设计模式
    JVM的异常处理
  • 原文地址:https://www.cnblogs.com/yingzhongwen/p/3516860.html
Copyright © 2011-2022 走看看