原创 leetcode--BinarySearch

L35: 常規二分查找   L278: 常規二分查找   L374: 常規二分查找   L367:perfect number 判斷一個數n是否是某個整數的平方 方1: N-1-3-5-7-9-…… == 0 ?

原创 leetcode--1、15、167 2Sum、3sum

L1: 無序數組找出相加爲target的兩個數 特徵:無序、無重複、每個元素只能用一次、有且只有一組答案 Tag:O(n) hashmap 解: Step1:hashmap中,key存儲number,value存儲inde

原创 leetcode--PascalTriangle

L118: 建立一個楊輝三角   L119: 將楊慧三角的第n行取出 點贊 收藏 分享 文章舉報 糊糊姨 發佈了26 篇原創文章 · 獲贊 0 · 訪問量

原创 C語言基礎--利用json文件load config信息

如果依賴json-c庫 jason文件格式: {  "achievement" : [ "ach1", "ach2", "ach3" ],   "age" : 23,   "name" : "Tsybius",   "partner"

原创 C語言基礎--讀文件

從一個文件中讀取數據到一塊buffer中 fp = fopen(file_path, "r"); if(fp == NULL) return -1; fseek(fp, 0, SEEK_END); unsigne

原创 leetcode--66.Plus One

L66: 將一個整數用一個數組表示,將這個整數+1。 Tips: 問題點在於是否進位。若進行到某一下標i,nums[i]<9, 則計算到此爲止。 vector<int>plusOne(vector<int>& digits)

原创 leetcode--547. Friend Circles

There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in natu

原创 LeetCode總結,二分法一般性總結

一,學習別人的總結與講解 本部分的參考見末尾,本部分文字是在其基礎上的二度總結(節約時間和精力)。 1,典型的二分法 算法:當數據量很大適宜採用該方法。採用二分法查找時,數據需是排好序的。  基本思想:假設數據是按升序排序的,對於給

原创 C語言基礎--測試程序中實現對FPS的控制

const int FRAMES_PER_SECOND = 25; const int SKIP_TICKS = 1000 / FRAMES_PER_SECOND; DWORD next_game_tick = GetTickCount

原创 leetcode--39. Combination Sum

Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C 

原创 leetcode--40. Combination Sum II

Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the cand

原创 leetcode--33. Search in Rotated Sorted Array

Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 mi

原创 leetcode--Remove Elements

Two Pointers   L26: RemoveDuplicatesFromSortedArray 有序數組,將重複的數刪除(放在數組尾端),並返回新數組長度。 Tips: For循環,用i遍歷數組。 只有num

原创 leetcode--8. String to Integer (atoi)

將string轉化爲int,要求包括: The function first discards as many whitespace characters as necessary until the first non-whites

原创 leetcode--18. 4Sum

Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all u