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

网站丢失了怎么找回来seo站内优化培训

网站丢失了怎么找回来,seo站内优化培训,网址seo查询,遂昌赶街网站【每日刷题】Day33 🥕个人主页:开敲🍉 🔥所属专栏:每日刷题🍍 🌼文章目录🌼 1. 20. 有效的括号 - 力扣(LeetCode) 2. 445. 两数相加 II - 力扣(…

【每日刷题】Day33

🥕个人主页:开敲🍉

🔥所属专栏:每日刷题🍍

🌼文章目录🌼

1. 20. 有效的括号 - 力扣(LeetCode)

2. 445. 两数相加 II - 力扣(LeetCode)

3. 1021. 删除最外层的括号 - 力扣(LeetCode)

1. 20. 有效的括号 - 力扣(LeetCode)

//思路:栈的基本使用。

typedef char STDataType;

typedef struct Stack

{

    STDataType* arr;

    int top;

    int capacity;

}ST;


//初始化栈

void StackInit(ST* st)

{

    st->arr = NULL;

    st->top = 0;

    st->capacity = 0;

}

//入栈

void StackPush(ST* st,STDataType s)

{

    assert(st);

    if(st->top==st->capacity)

    {

        int newcapacity = st->capacity == 0?4:2*st->capacity;

        STDataType* tmp = (STDataType*)realloc(st->arr,newcapacity*sizeof(STDataType));

        if(tmp==NULL)

        {

            perror("malloc:");

            exit(-1);

        }

        st->capacity = newcapacity;

        st->arr = tmp;

    }

    st->arr[st->top] = s;

    st->top++;

}

//获取栈顶元素

STDataType StackTop(ST* st)

{

    assert(st);

    assert(st->top>0);

    return st->arr[st->top-1];

}

//出栈

void StackPop(ST* st)

{

    assert(st);

    assert(st->top>0);

    st->top--;

}

//判断栈是否为空

bool StackEmpty(ST* st)

{

    assert(st);

    return st->top == 0;

}



 

bool isValid(char* s)

{

    ST st;

    StackInit(&st);//初始化栈

    while(*s)

    {

        if(*s=='{'||*s=='['||*s=='(')//如果遇到左括号,则入栈

        {

            StackPush(&st,*s);

        }

        else//如果遇到右括号,将栈中元素出栈

        {

            if(StackEmpty(&st))//如果前面没有入过栈,则直接返回

            {

                return false;

            }

            STDataType tmp = StackTop(&st);//先取得栈顶元素,判断是否与右括号匹配

            StackPop(&st);//出栈

            if((tmp=='('&&*s!=')')//如果不匹配,直接返回

            ||(tmp=='{'&&*s!='}')

            ||(tmp=='['&&*s!=']'))

            {

                return false;

            }

        }

        s++;

    }

    bool ret = StackEmpty(&st);//判断栈是否为空,为空说明所有左括号均与右括号匹配,为true,否则为false

    return ret;

}

2. 445. 两数相加 II - 力扣(LeetCode)

//思路:栈和链表的基本使用。

typedef struct ListNode LN;


 

int max(int x,int y)

{

    return x>y?x:y;

}

struct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2)

{

    LN* newhead = NULL;

    int i = 0;

    int j = 0;

    int arr1[100] = {0};

    int arr2[100] = {0};

    LN* pmove1 = l1;

    LN* pmove2 = l2;

    int flag = 0;

    while(pmove1)//链表1入栈

    {

        arr1[i++] = pmove1->val;

        pmove1 = pmove1->next;

    }

    while(pmove2)//链表2入栈

    {

        arr2[j++] = pmove2->val;

        pmove2 = pmove2->next;

    }

    i--;//定位栈顶元素

    j--;

    while(i>=0||j>=0)//两个栈同时出栈,元素相加,判断是否需要进位

    {

        LN* newnode = (LN*)malloc(sizeof(LN));//新节点,以头插的方式插入新链表

        newnode->next = newhead;

        newhead = newnode;

        int x = i>=0?arr1[i]:0;//栈1元素

        int y = j>=0?arr2[j]:0;//栈2元素

        int tmp = (x+y+flag)%10;

        newnode->val = tmp;

        if(x+y+flag>=10)//判断是否进位

        {

            flag = 1;

        }

        else

        {

            flag = 0;

        }

        if(i>=0)//防止栈越界访问

        {

            i--;

        }

        if(j>=0)

        {

            j--;

        }

    }

    if(flag)//如果出了循环,flag还为1,则说明最高位进了1,创建新节点,节点val为1,头插进链表中

    {

        LN* newnode = (LN*)malloc(sizeof(LN));

        newnode->next = newhead;

        newnode->val = 1;

        newhead = newnode;

    }

    return newhead;

}

3. 1021. 删除最外层的括号 - 力扣(LeetCode)

//0ms  100%思路:与第一题类似,栈的基础使用。

typedef int STDataType;

//栈结构体

typedef struct Stack

{

    STDataType* arr;

    int top;

    int capacity;

}ST;



 

//初始化栈

void StackInit(ST* st)

{

    assert(st);

    st->arr = NULL;

    st->capacity = st->top = 0;

}


 

//释放栈

void StackRelease(ST* st)

{

    assert(st);

    free(st->arr);

    st->arr = NULL;

    st->capacity = st->top = 0;

}


 

//判空

bool StackEmpty(ST* st)

{

    assert(st);

    return st->top == 0;

}



 

//入栈

void StackPush(ST* st, STDataType x)

{

    assert(st);

    if (st->top == st->capacity)

    {

        int newcapacity = st->capacity == 0 ? 4 : 2 * st->capacity;

        STDataType* tmp = (STDataType*)realloc(st->arr,sizeof(STDataType) * newcapacity);

        if (tmp == NULL)

        {

            perror("malloc:");

            exit(-1);

        }

        st->arr = tmp;

        st->capacity = newcapacity;

    }

    st->arr[st->top] = x;

    st->top++;

}


 

//出栈

void StackPop(ST* st)

{

    assert(st);

    assert(st->top > 0);

    st->top--;

}



 

//获取栈顶元素

STDataType StackTop(ST* st)

{

    assert(st);

    assert(st->top > 0);

    return st->arr[st->top - 1];

}


 

char* removeOuterParentheses(char* s)

{

    ST st;

    StackInit(&st);//初始化栈

    char* arr = (char*)malloc(sizeof(char)*100000);//新空间存储删除后的字符串

    int count = 0;

    while(*s)

    {

        if(*s=='(')//如果为左括号入栈

        {

            StackPush(&st,*s);

        }

        if(st.top>1)//如果栈中元素大于1,说明当前*s不是要删除的括号,直接放入创建好的空间中

        {

            arr[count++] = *s;

        }

        if(*s==')')//如果是右括号,与栈中左括号匹配,出栈

        {

            StackPop(&st);

        }

        s++;

    }

    arr[count] = '\0';

    return arr;

}

http://www.hkea.cn/news/884012/

相关文章:

  • 重庆网站建设零臻靠谱国内永久免费的云服务器
  • 软件库合集软件资料2024郑州百度快照优化
  • 房地产开发公司网站建设方案seo去哪里学
  • 做网站可以赚钱吗百度小说搜索风云排行榜
  • 做网站交接需要哪些权限网站seo视频教程
  • 在网站怎么做收款二维码刷移动关键词优化
  • 问信息奥赛题怎么做 去哪个网站互联网网络推广
  • b2c电子商务网站系统下载专业网站seo推广
  • 引流推广的方法seo诊断工具
  • 平阴县建设工程网站直通车推广怎么做
  • 网站开发外包不给ftp高佣金app软件推广平台
  • 太原适合网站设计地址百度用户服务中心客服电话
  • 济南源码网站建设长沙网站seo推广公司
  • 北京网站制作17页和业务多一样的平台
  • 无锡市住房城乡建设委网站简单网页设计模板html
  • 武汉市大型的网站制作公司网站ip查询
  • 做仪表行业推广有哪些网站电商网站设计
  • 动静分离网站架构百度售后客服电话24小时
  • 做汽车配件生意的网站佛山seo关键词排名
  • 创意建站推荐百度做广告多少钱一天
  • 巴中网站建设公司百度seo怎么做网站内容优化
  • 查网站备案名称上海网络营销seo
  • 人是用什么做的视频网站网络营销方案设计毕业设计
  • 建设网站考虑因素关键词优化是怎么弄的
  • 陕西营销型网站建设推广普通话的内容简短
  • 做配电箱的专门网站百度指数属于行业趋势及人群
  • 学做网站的网站重庆seo整站优化报价
  • 保定网站设计概述seo推广软件排名
  • 查pv uv的网站网络营销推广服务
  • 怎样让客户做网站优化 保证排名