原创 leetcode題目 尋找和爲SUM的集合系列問題

題目一: Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidat

原创 leetcode題目 丟失的第一個正數

題目: Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3,

原创 leetcode題目 跳躍遊戲系列題目

題目一: Given an array of non-negative integers, you are initially positioned at the first index of the array. Each eleme

原创 leetcode題目 反轉鏈表系列問題

題目1: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you shou

原创 leetcode題目 二分查找升級版

題目: Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm’s r

原创 leetcode題目 尋找和爲SUM的兩數(O(nlogn)和O(n)解法)

leetcode第一題 題目: Given an array of integers, find two numbers such that they add up to a specific target number. The fu

原创 泛型算法之二分查找

泛型算法之二分查找實現,及簡單測試。查找範圍可以是C++內置指針或者容器的迭代器,查找內容可以是char,int等類型 #include <string> #include <iostream> #include <vector> #in

原创 leetcode題目 尋找最長迴文字串

題目: Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000,

原创 leetcode題目 尋找兩個排序數組的中位數

題目: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays.

原创 泛型算法之直接插入

直接插入的泛型算法實現,沒有哨兵,直接通過下標進行邊界控制。 #include <iostream> #include <vector> using namespace std; template<typename Randomacce

原创 360筆試編程題 找老鄉(BFS解法)

題目:大學的同學來自全國各地,對於遠離家鄉步入陌生大學校園的大一新生來說,碰到老鄉是多麼激動的一件事,於是大家都熱衷於問身邊的同學是否與自己同鄉。來自新疆的小鯢尤其熱衷。但是大家都不告訴小尼他們來自哪裏,只是說與誰同鄉。從所給的信息中,你

原创 搜狗16招聘機試題 加密解密算法

題目:下面程序中,shuffle函數用於把整數數列打散,函數參數seed是一個隨機種子,同一個隨機種子產生一個確定的隨機序列。請爲shuffle寫一個還原函數(restore)。其輸入是經過shuffle打散的整數數列a[]以及打散時使用

原创 微軟筆試編程題 求多少個子序列符合斐波那契排列

描述 Given a sequence {an}, how many non-empty sub-sequence of it is a prefix of fibonacci sequence. A sub-sequence is a

原创 leetcode題目 聚合相同的字母組成的單詞

題目: Given an array of strings, group anagrams together. For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”]

原创 leetcode題目 合併N個排序好的鏈表

題目: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 思路: 兩種方法,第一種思路