原创 PHP求數組的差集和交集

array_intersect()函數返回一個保留了鍵的數組,這個數組只由第一個數組中出現的且在其他每個輸入數組中都出現的值組成。其形式如下: 1 array array_intersect(array array1,

原创 第一個只出現一次的字符(Hash)

#include<iostream> #include<stdlib.h> using namespace std; //題目要求:在字符串中找出第一個只出現一次的字符,如輸入"abaccdeff",則輸出b。 //傳統方法的時間複雜度

原创 數組中c出現次數超過一半的數字

#include<iostream> using namespace std; //最後出現1的肯定就是出現一半的字符 int MoreThanhalfnum(int *numbers,int length){ if(numbers

原创 醜數(空間換時間)

#include <iostream> #include <stdlib.h> using namespace std; int Getuglynumber(int index); int Min(int number1,int num

原创 2017京東面試雜談

好歹第一次出去面試,把他過程經歷寫下來,與諸君共勉。 1.筆試 筆試的話,是在線筆試的,大公司現在都喜歡用這個套路,因爲筆試不用組織人啊去弄卷子啊,組織考場啊,巴拉巴拉的,所以說應該簡歷還算合格的都可以有筆試的資格。 筆試的題,就是大學四

原创 PHP如何判斷一個數組是一維的還是二維的

1.首先我們有一個PHP內置函數 count(); count(array,mode); array是數組,mode默認爲0,1是遞歸的計數 <?php if(count($arr) == count($arr,1)){ e

原创 PHP數組元素的順序和逆序排列

對一個數組的元素排序是很常見的編程任務,比如順序、逆序,還有排序是否保持元素的鍵值對問題,下面開始研究下這些問題。 sort()函數 sort()函數對數組進行排序,各元素按值由低到高的順序排列。其形式如下:

原创 合併兩個排序的鏈表

#include<stdio.h> #include<stdlib.h> #include<string.h> struct Node{ int m_value; Node *m_next; }; //遞歸方式 Node* Mer

原创 vc++vector用法

在c++中,vector是一個十分有用的容器,下面對這個容器做一下總結。 1 基本操作 (1)頭文件#include<vector>. (2)創建vector對象,vector<int> vec; (3)尾部插入數字:vec.p

原创 輸入一個矩陣,按照從外向裏順時針的順序依次打印出每一個數字

#include<iostream> #include<stack> using namespace std; //輸入一個矩陣,按照從外向裏順時針的順序依次打印出每一個數字 void printMatrix(int** numbe

原创 樹的子結構

#include <iostream> #include <stack> using namespace std; struct BinaryTreeNode{ char t_value; BinaryTreeNode *t_le

原创 二叉搜索樹轉化爲有序雙向鏈表

#include<iostream> using namespace std; struct BinaryTreeNode{ int m_value; BinaryTreeNode* m_left; BinaryTreeNode*

原创 調整數組順序使得奇數在偶數前面

#include <stdio.h> #include <stdlib.h> #include <string.h> void RecorderOddEvent(int *pData,unsigned int length){ if(

原创 遍歷一遍找出鏈表倒數第K個節點

#include <stdio.h> #include <stdlib.h> #include <string.h> //類似的問題還有求鏈表的中間節點判斷一個單向鏈表是否形成了環形結構 struct Node{ int node_

原创 二叉樹中和爲某一值的路徑

#include<iostream> #include<stack> #include<vector> using namespace std; struct BinaryTreeNode{ int m_value; BinaryT