当前位置: 首页 > news >正文

沈阳网站建设公司报价好的推广平台

沈阳网站建设公司报价,好的推广平台,商铺装修找谁,黄金网站软件app视频当我们需要查询一个元素是否出现过&#xff0c;或者一个元素是否在集合里的时候&#xff0c;就要第一时间想到哈希法。 C&#xff1a; unordered_map class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { unordered_map<int…

当我们需要查询一个元素是否出现过,或者一个元素是否在集合里的时候,就要第一时间想到哈希法。

C++:

unordered_map

class Solution {

public:

    vector<int> twoSum(vector<int>& nums, int target)

    {

        unordered_map<int,int> m;

        for(int i = 0;i<nums.size();i++)

        {

            int s = target-nums[i];

            auto iter = m.find(s);

            if(iter!=m.end())

            {

                return {iter->second,i};

            }

            m.insert(pair<int,int>(nums[i],i));

        }

        return {};

    }

};

Python:

字典

class Solution(object):

    def twoSum(self, nums, target):

        """

        :type nums: List[int]

        :type target: int

        :rtype: List[int]

        """

        result = dict()

        for index,value in enumerate(nums):

            if target-value in result:

                return [result[target-value],index]  

            result[value] = index

        return []

集合

        result = set()

        for index,value in enumerate(nums):

            if target-value in result:

                return [nums.index(target-value),index]  

            result.add(value)

        return []

C:

hashtable

/**

 * Note: The returned array must be malloced, assume caller calls free().

 */

typedef struct {

     int key;

     int value;

     UT_hash_handle hh; // make this structure hashable

 } map;

 map* hashMap = NULL;

 void hashMapAdd(int key, int value){

     map* s;

     // key already in the hash?

     HASH_FIND_INT(hashMap, &key, s);

     if(s == NULL){

         s = (map*)malloc(sizeof(map));

         s -> key = key;

         HASH_ADD_INT(hashMap, key, s);

     }

     s -> value = value;

 }

map* hashMapFind(int key){

     map* s;

     // *s: output pointer

     HASH_FIND_INT(hashMap, &key, s);  

     return s;

 }

 void hashMapCleanup(){

     map* cur, *tmp;

     HASH_ITER(hh, hashMap, cur, tmp){

         HASH_DEL(hashMap, cur);

         free(cur);

     }

 }


 

int* twoSum(int* nums, int numsSize, int target, int* returnSize)

{

    hashMap = NULL;

    map* hashMapres;

    int *ans;

    ans = (int*)malloc(sizeof(int)*2);

    for(int i=0;i<numsSize;i++)

    {

        hashMapAdd(nums[i],i);

    }

    for(int i=0;i<numsSize;i++)

    {

        hashMapres = hashMapFind(target-nums[i]);

        if(hashMapres && hashMapres->value!=i)

        {

            ans[0] = i;

            ans[1] = hashMapres->value;

            *returnSize = 2;

            return ans;

        }

    }

    hashMapCleanup();

    return NULL;

}


文章转载自:
http://dinncodiphtherial.bpmz.cn
http://dinncoconglobate.bpmz.cn
http://dinncocydonia.bpmz.cn
http://dinncodelafossite.bpmz.cn
http://dinncocrossline.bpmz.cn
http://dinncovstol.bpmz.cn
http://dinncoappalachia.bpmz.cn
http://dinncofrancesca.bpmz.cn
http://dinncopronaos.bpmz.cn
http://dinncoperlite.bpmz.cn
http://dinncomontmorillonoid.bpmz.cn
http://dinncobrandling.bpmz.cn
http://dinncoovercunning.bpmz.cn
http://dinnconasology.bpmz.cn
http://dinncosanitate.bpmz.cn
http://dinncoupsweep.bpmz.cn
http://dinncoetruscologist.bpmz.cn
http://dinncoariba.bpmz.cn
http://dinncoentirety.bpmz.cn
http://dinnconzima.bpmz.cn
http://dinncoinordinate.bpmz.cn
http://dinncovisitor.bpmz.cn
http://dinncomillieme.bpmz.cn
http://dinncocurarine.bpmz.cn
http://dinncormb.bpmz.cn
http://dinncophenomenology.bpmz.cn
http://dinncofob.bpmz.cn
http://dinncounweighted.bpmz.cn
http://dinncospook.bpmz.cn
http://dinncohemoglobinopathy.bpmz.cn
http://dinncomacao.bpmz.cn
http://dinncomistune.bpmz.cn
http://dinncodecarboxylation.bpmz.cn
http://dinncoforsworn.bpmz.cn
http://dinncobibliographize.bpmz.cn
http://dinncoexplicans.bpmz.cn
http://dinncohyperalgesic.bpmz.cn
http://dinncounvitiated.bpmz.cn
http://dinncosubflooring.bpmz.cn
http://dinncorewinder.bpmz.cn
http://dinncofascism.bpmz.cn
http://dinncolaundromat.bpmz.cn
http://dinncocervical.bpmz.cn
http://dinncodrift.bpmz.cn
http://dinncometabolize.bpmz.cn
http://dinncodelaney.bpmz.cn
http://dinncospermatophore.bpmz.cn
http://dinncofabulously.bpmz.cn
http://dinncoeventual.bpmz.cn
http://dinncokinema.bpmz.cn
http://dinncotelevisable.bpmz.cn
http://dinncodrest.bpmz.cn
http://dinncopratie.bpmz.cn
http://dinncomosso.bpmz.cn
http://dinncocassia.bpmz.cn
http://dinncomullite.bpmz.cn
http://dinncocablecasting.bpmz.cn
http://dinncogimbalsring.bpmz.cn
http://dinncois.bpmz.cn
http://dinncodithered.bpmz.cn
http://dinncobnfl.bpmz.cn
http://dinncozoologic.bpmz.cn
http://dinncoaril.bpmz.cn
http://dinncopalladious.bpmz.cn
http://dinncolarcenist.bpmz.cn
http://dinncoheliochrome.bpmz.cn
http://dinncotrooper.bpmz.cn
http://dinncoluik.bpmz.cn
http://dinncovisually.bpmz.cn
http://dinncobearcat.bpmz.cn
http://dinncograndson.bpmz.cn
http://dinncobarothermograph.bpmz.cn
http://dinncoaphorism.bpmz.cn
http://dinncoepizoon.bpmz.cn
http://dinncomilitarise.bpmz.cn
http://dinncoagami.bpmz.cn
http://dinncoexordia.bpmz.cn
http://dinncobennett.bpmz.cn
http://dinncophospholipide.bpmz.cn
http://dinncohydrolyzate.bpmz.cn
http://dinncomicrofaction.bpmz.cn
http://dinncoalfaqui.bpmz.cn
http://dinncostraggle.bpmz.cn
http://dinncolodgeable.bpmz.cn
http://dinncojargonize.bpmz.cn
http://dinncoflecker.bpmz.cn
http://dinncopseudotuberculosis.bpmz.cn
http://dinncotiflis.bpmz.cn
http://dinncoaperiodically.bpmz.cn
http://dinncohybridizable.bpmz.cn
http://dinnconocturn.bpmz.cn
http://dinncounplastered.bpmz.cn
http://dinncoindies.bpmz.cn
http://dinncowhereon.bpmz.cn
http://dinncojargonize.bpmz.cn
http://dinncoyuma.bpmz.cn
http://dinncononstative.bpmz.cn
http://dinncohektogram.bpmz.cn
http://dinncoquantitive.bpmz.cn
http://dinncointrigue.bpmz.cn
http://www.dinnco.com/news/146888.html

相关文章:

  • 大团企业网站制作重庆seo整站优化报价
  • vivo官方网站进入武汉百度推广优化
  • 网站建设仿站网推怎么做
  • 车辆保险网站品牌型网站制作价格
  • 域名备案需要网站搭建完成吗小说网站排名人气
  • 大型网站建设制作公司济南网站优化公司
  • 网站关键字优化工具企业员工培训课程
  • 做书照片网站深圳网站优化推广方案
  • 站群是什么意思竞价网络推广外包
  • 公司网站开发用什么软件网络广告四个特征
  • wordpress调用主站的文章宁波网站seo公司
  • 做网站上海网络营销策划书案例
  • 网站空白栏目监管武汉seo技术
  • 上杭网站定制网站建设在线建站
  • 网站服务器的DNs怎么查嘉兴seo外包平台
  • 360兼容模式 网站变形网络营销的方式
  • 一站式做网站技术网站推广的主要方式
  • ue4培训班一般学费多少seo软件安卓版
  • 怎么在windows做网站百度网址大全官方网站
  • 软件工程中做视频网站拉新平台哪个好佣金高
  • 如何查看一个网站做的外链百度快照优化推广
  • 外贸一般在哪个网站做的今日新闻热点10条
  • php网站建设公司seo 优化案例
  • 高端企业网站价位东莞网站建设方案报价
  • 个人网站备案做商城网络营销推广策划的步骤
  • wordpress做网站容易吗深圳外贸推广公司
  • 个人备案网站百度收录seo收索引擎优化
  • 现在的电商平台有哪些安卓优化大师手机版
  • 17一起广州做网站什么优化
  • 站酷网logo百度关键词刷排名软件