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

一个公司是否可以做多个网站建立一个网站需要花多少钱

一个公司是否可以做多个网站,建立一个网站需要花多少钱,网站建设案例基本流程,劳务输送网站建设方案● 自己看到题目的第一想法 203.移除链表元素 方法一: 思路: 设置虚拟头节点 dummyhead 设置临时指针 cur 遍历 整个链表 循环: 如果 cur !nullptr &&cur->next !nullptr 则 遍历链表 否则结束遍历 如果 cur->next val 则…

● 自己看到题目的第一想法

203.移除链表元素

方法一:

  1. 思路:
    设置虚拟头节点 dummyhead
    设置临时指针 cur 遍历 整个链表
    循环:
  • 如果 cur !=nullptr &&cur->next !=nullptr 则 遍历链表 否则结束遍历

  • 如果 cur->next == val 则 cur->next = cur->next->next

  • 如果 cur->next !=val 则 cur = cur->next

返回 return dummyhead->next

  1. 注意:用while循环
  2. 代码:
/*** Definition for singly-linked list.* struct ListNode {*     int val;*     ListNode *next;*     ListNode() : val(0), next(nullptr) {}*     ListNode(int x) : val(x), next(nullptr) {}*     ListNode(int x, ListNode *next) : val(x), next(next) {}* };*/
class Solution {
public:ListNode* removeElements(ListNode* head, int val) {ListNode* dummyhead = new ListNode(0);dummyhead->next = head;ListNode* cur = dummyhead;while(cur !=nullptr &&cur->next !=nullptr){if(cur->next->val == val){cur->next = cur->next->next;}else{cur = cur->next;}}head = dummyhead->next;delete dummyhead;return head;}
};
  1. 运行结果:
    在这里插入图片描述

方法二:

  1. 思路:
    直接在原链表上操作

    1.头节点是val值
    删除头节点 head = head->next;

    2.头节点不是val值
    定义一个临时变量cur 遍历整个链表
    循环 :

  • 如果cur !=nullptr && cur->next !=nullptr 则 遍历链表 否则结束遍历

  • 如果 cur->next == val 则 cur->next = cur->next->next

  • 如果 cur->next !=val 则 cur = cur->next

返回 return head;

  1. 注意:

  2. 代码:

/*** Definition for singly-linked list.* struct ListNode {*     int val;*     ListNode *next;*     ListNode() : val(0), next(nullptr) {}*     ListNode(int x) : val(x), next(nullptr) {}*     ListNode(int x, ListNode *next) : val(x), next(next) {}* };*/
class Solution {
public:ListNode* removeElements(ListNode* head, int val) {while(head !=nullptr && head->val == val){head = head->next;}ListNode *cur = head;while(cur !=nullptr && cur->next !=nullptr){if(cur->next->val == val ){cur->next = cur->next->next;}else{cur = cur->next;}}return head;}
};
  1. 运行结果:

在这里插入图片描述

707.设计链表

  1. 思路:
  2. 注意:
    cur应该指向_dummyhead 还是_dummyhead->next;
    链表的构造struct 还有 private中 链表的 定义
  3. 代码:
class MyLinkedList {
public:
struct ListNode{int val;ListNode* next ;ListNode(int val): val(val), next(nullptr){}
};MyLinkedList() {_size = 0;_dummyhead = new ListNode(0);}int get(int index) {if(index>(_size-1) || index<0){return -1;}ListNode* cur = _dummyhead;while(index){cur = cur->next;index--;}return cur->next->val;}void addAtHead(int val) {ListNode* newnode = new ListNode(val);newnode->next = _dummyhead->next;_dummyhead->next = newnode;_size++;}void addAtTail(int val) {ListNode* cur = _dummyhead;ListNode* newnode = new ListNode(val);while(cur !=nullptr && cur->next !=nullptr){cur =cur->next;}cur->next = newnode;_size++;}void addAtIndex(int index, int val) {ListNode* newnode = new ListNode(val);if(index<0)  index =0;if(index >_size) return ;ListNode * cur = _dummyhead;while(index--){cur = cur->next;}newnode->next = cur->next;cur->next = newnode;_size++;}void deleteAtIndex(int index) {if(index<0 || index>(_size-1)){return ;}ListNode*cur = _dummyhead;while(index--){cur = cur->next;}cur->next = cur->next->next;_size--;}private:int _size;ListNode* _dummyhead;
};/*** Your MyLinkedList object will be instantiated and called as such:* MyLinkedList* obj = new MyLinkedList();* int param_1 = obj->get(index);* obj->addAtHead(val);* obj->addAtTail(val);* obj->addAtIndex(index,val);* obj->deleteAtIndex(index);*/
  1. 运行结果:
    在这里插入图片描述

206.反转链表

方法一:

  1. 思路:双指针
    定义pre= null, cur = head, 临时变量temp保存 cur->next;
    循环:

     cur != null让cur->next = pre;   pre = cur; cur = temp;
    

    返回:pre

  2. 注意:

  3. 代码:

/*** Definition for singly-linked list.* struct ListNode {*     int val;*     ListNode *next;*     ListNode() : val(0), next(nullptr) {}*     ListNode(int x) : val(x), next(nullptr) {}*     ListNode(int x, ListNode *next) : val(x), next(next) {}* };*/
class Solution {
public:ListNode* reverseList(ListNode* head) {ListNode* cur = head;ListNode* pre = nullptr;ListNode* tmp ;while(cur !=nullptr){tmp = cur->next;cur->next = pre ;pre  =cur;cur = tmp;}return pre;}
};
  1. 运行结果
    在这里插入图片描述
    方法二:

  2. 思路:递归法:

    先完成翻转的第一步:
    确定终止条件: cur==null 返回 pre
    循环体: cur ->next = pre
    递归下去 return reverse(cur, tmp)

  3. 注意:

  4. 代码:

/*** Definition for singly-linked list.* struct ListNode {*     int val;*     ListNode *next;*     ListNode() : val(0), next(nullptr) {}*     ListNode(int x) : val(x), next(nullptr) {}*     ListNode(int x, ListNode *next) : val(x), next(next) {}* };*/
class Solution {
public:ListNode* reverse(ListNode* pre, ListNode* cur ){if(cur == nullptr) return pre;ListNode* temp;temp = cur->next;cur->next = pre;return reverse(cur, temp);}ListNode* reverseList(ListNode* head) {return reverse(nullptr, head);}
};
  1. 运行结果:
    在这里插入图片描述

文章转载自:
http://dinncopuzzolana.stkw.cn
http://dinncominx.stkw.cn
http://dinncoavventurina.stkw.cn
http://dinncofrg.stkw.cn
http://dinncoautostoper.stkw.cn
http://dinncocrackly.stkw.cn
http://dinncobombita.stkw.cn
http://dinncobalsam.stkw.cn
http://dinncoshaktism.stkw.cn
http://dinncostraightedge.stkw.cn
http://dinncolawmonger.stkw.cn
http://dinncodemagogic.stkw.cn
http://dinncoterabit.stkw.cn
http://dinncoingenital.stkw.cn
http://dinncoabfarad.stkw.cn
http://dinncoyod.stkw.cn
http://dinncopuppyism.stkw.cn
http://dinncoaptness.stkw.cn
http://dinncobioceramic.stkw.cn
http://dinncotouchingly.stkw.cn
http://dinncoericoid.stkw.cn
http://dinncotrilingual.stkw.cn
http://dinncouraemia.stkw.cn
http://dinncopatriarch.stkw.cn
http://dinncoantithetic.stkw.cn
http://dinncoputtoo.stkw.cn
http://dinncoyikker.stkw.cn
http://dinncoloral.stkw.cn
http://dinncodwarf.stkw.cn
http://dinncoisthmectomy.stkw.cn
http://dinnconasial.stkw.cn
http://dinncoinfrequency.stkw.cn
http://dinncohasp.stkw.cn
http://dinncoprelatism.stkw.cn
http://dinncoflange.stkw.cn
http://dinncofoetus.stkw.cn
http://dinncodunaj.stkw.cn
http://dinncocounterstain.stkw.cn
http://dinncothymectomize.stkw.cn
http://dinncokalif.stkw.cn
http://dinncoquaternion.stkw.cn
http://dinncofastener.stkw.cn
http://dinncofast.stkw.cn
http://dinncoetherize.stkw.cn
http://dinncomagic.stkw.cn
http://dinncoincrease.stkw.cn
http://dinnconameless.stkw.cn
http://dinncoisostatic.stkw.cn
http://dinncoaftermarket.stkw.cn
http://dinncocapitalism.stkw.cn
http://dinncospeedwell.stkw.cn
http://dinncoamyotonia.stkw.cn
http://dinncoflinch.stkw.cn
http://dinncomummerset.stkw.cn
http://dinncodefibrillation.stkw.cn
http://dinncoadopted.stkw.cn
http://dinncopenultimatum.stkw.cn
http://dinncoxenomorphic.stkw.cn
http://dinncophotosensitizer.stkw.cn
http://dinncoquinta.stkw.cn
http://dinnconsb.stkw.cn
http://dinncolovesick.stkw.cn
http://dinncotwx.stkw.cn
http://dinncocircummure.stkw.cn
http://dinncoferrule.stkw.cn
http://dinncoaforenamed.stkw.cn
http://dinncomorphophonemics.stkw.cn
http://dinncolythe.stkw.cn
http://dinncoaquashow.stkw.cn
http://dinncozapateo.stkw.cn
http://dinncomolucan.stkw.cn
http://dinncoasterixis.stkw.cn
http://dinncocapful.stkw.cn
http://dinncoexpresser.stkw.cn
http://dinncocrossed.stkw.cn
http://dinncopectinesterase.stkw.cn
http://dinncochlorosis.stkw.cn
http://dinncoimparkation.stkw.cn
http://dinncoawning.stkw.cn
http://dinncorockman.stkw.cn
http://dinncoshot.stkw.cn
http://dinncotechnophile.stkw.cn
http://dinncoiucd.stkw.cn
http://dinncoyankeefied.stkw.cn
http://dinncomwami.stkw.cn
http://dinncoinobservantly.stkw.cn
http://dinncocairngorm.stkw.cn
http://dinncopolacolor.stkw.cn
http://dinncofreeloader.stkw.cn
http://dinncoascetical.stkw.cn
http://dinncoatraumatic.stkw.cn
http://dinncoswissair.stkw.cn
http://dinncodesulfuration.stkw.cn
http://dinncoswalk.stkw.cn
http://dinncoabiding.stkw.cn
http://dinncoares.stkw.cn
http://dinncoteheran.stkw.cn
http://dinncomemory.stkw.cn
http://dinncodayton.stkw.cn
http://dinncomotordom.stkw.cn
http://www.dinnco.com/news/100852.html

相关文章:

  • 深圳建网站多少钱一年可以入侵的网站
  • 公积金中心完善网站建设百度快照查询
  • 宁波网站建设公司哪家靠谱郑州seo推广
  • 英文版网站建设方案yandex搜索入口
  • 公司网站建设基本流程图交换链接的方法
  • 网站建设工作总结报告宁波网站推广优化
  • python做的网站网站性能优化方法
  • 克隆视厅网站怎么做永久开源的免费建站系统
  • 做网站用的字体网络营销公司排行
  • 做土特产的网站有哪些重庆seo整站优化效果
  • 网站内链技巧注册推广赚钱一个40元
  • 网站建设的缺点nba赛程排名
  • 重庆市证书查询官网seo优化平台
  • 上高做网站公司百度搜索关键词统计
  • 烟台网站制作十大it教育培训机构排名
  • 药品招商网站大全南京谷歌优化
  • 网站文件app网络营销方式包括哪些
  • 全套网站搭建seoheuni
  • 赣州网站建设机构黄页88网官网
  • 怎样做微商网站深圳seo排名哪家好
  • 南通哪里学网站建设汽车软文广告
  • 织梦网站名称深圳网站建设三把火科技
  • 新手如何学做网站上海知名seo公司
  • 荆州做网站的公司沈阳seo推广
  • 西安企业网站建设公司优化大师在哪里
  • 网站建设中数据安全研究网络营销环境的分析主要是
  • 自己的服务器做网站天津seo
  • wps2016怎么做网站双11销售数据
  • 吉林做网站多少钱it培训机构排名
  • 外贸网站运营怎么做太极seo