Time: 2015-09-09 14:40 ~ 15:40
Location: No. 1th, Wang Zhuang Road, Haidian District , Beijing Tongfang Science and Technology Plaza, Block D, West 7
1. Ask project experience and what books you have read
2. There are 3n+1 integers, with only one number appearing once, and the other numbers appearing 3 times to find the only one that appears once.
https://leetcode.com/problems/single-number-ii/
https://github.com/loverszhaokai/leetcode/blob/master/137_no/sol_bit_manipulation.cc
#include <climits>#include<cmath>#include<cstdlib>#include<cstring>#include<iostream>#include<iomanip>#include<string>#include<vector>using namespacestd;intFindConstvector<int> &nums) { intcount[ +]; for(intIII =0; III <sizeof(count)/sizeof(int); iii++) COUNT[III]=0; for(intIII =0; III < nums.size (); iii++) { intJJJ =1; intKKK =1; while(JJJ <= +) { if(NUMS[III] &KKK) COUNT[JJJ-1] = (COUNT[JJJ-1] +1) %3; KKK<<=1; JJJ++; } } intAns =0; intJJJ =1; for(intIII =0; III <sizeof(count)/sizeof(int); iii++) { if(COUNT[III]) ans|=JJJ; JJJ<<=1; } returnans;}//Use of both integer instead of count[32]//0 0-0//0 1-1//1 0-2//intFind2 (Constvector<int> &nums) { intHigh =0; intLow =0; for(intIII =0; III < nums.size (); iii++) { intJJJ =1; intKKK =1; while(JJJ <= +) { if(NUMS[III] &KKK) { if((High & KKK) ^ (Low & KKK) ^KKK) Low|=KKK; Else Low&= ~KKK; if((High & KKK) ^ (Low & KKK) ^KKK) high|=KKK; Else High&= ~KKK; } KKK<<=1; JJJ++; } } intAns =0; intIII =1; intJJJ =1; while(iii <= +) { if(Low & JJJ | |, High &jjj) ans|=JJJ; JJJ<<=1; III++; } returnans;}intMain () {Const structTestCase {vector<int>Nums; intret; } test_cases[]= { { { 1,1,1,3 }, 3 }, { { 1,1,1,2,3,2,2 }, 3 }, { { 1,1,1,2,3,2,2,3,4,3 }, 4 }, }; for(intIII =0; III <sizeof(test_cases)/sizeof(TestCase); iii++) { ConstTestCase &TC =TEST_CASES[III]; intActual_ret =find (Tc.nums); if(Tc.ret! =Actual_ret) {cout<<"Case #"<< III <<": FAILED"<<Endl; cout<<"\texpected ret="<< Tc.ret <<Endl; cout<<"\tacutal ret="<< Actual_ret <<Endl; } Actual_ret=Find2 (tc.nums); if(Tc.ret! =Actual_ret) {cout<<"Case #"<< III <<": FAILED"<<Endl; cout<<"\texpected ret="<< Tc.ret <<Endl; cout<<"\tacutal ret="<< Actual_ret <<Endl; } } return 0;}
3. Ask the project on GitHub and recommend typochecker use the trie tree.
2015-09-09 [Little information]--data capture and processing engineer--4 face