# 2015-09-09 [Little information]--data capture and processing engineer--4 face

Source: Internet
Author: User

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

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 &AMP;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

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.