原创 21 - Merge Two Sorted Lists - LeetCode

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes o

原创 關於編程素養

個人記錄一下,想到的幾點編程的基本素養: 1. 參數檢查非常重要,在每個單獨的函數中,開始都應該進行參數檢查。     如果參數爲空,則拋異常至上一級,或者根據需求賦默認值,且輸出操作日誌。 2. 每個函數體,記得放入try catch

原创 [bug] Field 'id' doesn't have a default value

在使用 spring + Hibernate + JPA 連接 Mysql時,報錯如下: bug:Field 'id' doesn't have a default value 原因是因爲自己粗心,主鍵id並沒有自增,沒有勾選:AUTO_

原创 258 - Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: G

原创 分治法 - 歸併排序

歸併排序是分治法的典型應用,思想如下: divide:divide the array to 2 subarray conquer:reverse in 2 subarray,if only one elem ,return combin

原创 100 - SameTree

Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if t

原创 8 - String to Integer (atoi)

Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a ch

原创 爲 vector 重載 << (輸出操作符)

代碼如下: #include <iostream> #include <vector> using namespace std; ostream& operator<< (ostream& out, vector<string>& _

原创 2 - Add Two Numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each

原创 1- Two Sum

Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum s

原创 169- Majority Element

Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/

原创 中國將帥象棋問題

#include <stdio.h> #define HALF_BITS_LENGTH 4 #define FULLMASK 255 // 1111 1111 #define LMASK (FULLMASK << HALF_BIT