<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 查找出現次數的奇數 > 原文: [https://www.geeksforgeeks.org/find-the-number-occurring-odd-number-of-times/](https://www.geeksforgeeks.org/find-the-number-occurring-odd-number-of-times/) 給定一個正整數數組。 除一個數字為奇數次外,所有數字均出現偶數次。 在`O(n)`時間&恒定空間中找到數字。 **示例**: ``` Input : arr = {1, 2, 3, 2, 3, 1, 3} Output : 3 Input : arr = {5, 7, 2, 7, 5, 2, 5} Output : 5 ``` **簡單解決方案**是運行兩個嵌套循環。 外循環一一拾取所有元素,內循環計數外循環拾取的元素的出現次數。 該解決方案的時間復雜度為 `O(n^2)`。 以下是暴力方法的實現: ## C++ ```cpp // C++ program to find the element? // occurring odd number of times #include<bits/stdc++.h> using namespace std; // Function to find the element? // occurring odd number of times int getOddOccurrence(int arr[], int arr_size) { ????for (int i = 0; i < arr_size; i++) { ????????int count = 0; ????????for (int j = 0; j < arr_size; j++) ????????{ ????????????if (arr[i] == arr[j]) ????????????????count++; ????????} ????????if (count % 2 != 0) ????????????return arr[i]; ????} ????return -1; } // driver code int main() ????{ ????????int arr[] = { 2, 3, 5, 4, 5, 2, ??????????????????????4, 3, 5, 2, 4, 4, 2 }; ????????int n = sizeof(arr) / sizeof(arr[0]); ????????// Function calling ????????cout << getOddOccurrence(arr, n); ????????return 0; ????} ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看