ARTS-第12周-190603

Algorithm
4Sum

Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.
给出一个有n个数字的整形数组,找出里面4个数相加等于目标数字的组。
例如:
输入:数组 nums = [1, 0, -1, 0, -2, 2], 目标数 target = 0.
结果是:
[
[-1, 0, 0, 1],
[-2, -1, 1, 2],
[-2, 0, 0, 2]
]

这题和之前的 3Sum有点类似,相当于确定一个值以后在剩余的数组中计算3sum。

static public IList<IList<int>> FourSum(int[] nums, int target)
{
    IList<IList<int>> result = new List<IList<int>>();
    if (nums.Length < 4)
    {
        return result;
    }
    for (int times = 1; times <= nums.Length - 1; times++)
    {
        for (int start = 0; start < nums.Length - times; start++)
        {
            if (nums[start] > nums[start + 1])
            {
                int cur_num = nums[start];
                nums[start] = nums[start + 1];
                nums[start + 1] = cur_num;
            }
        }
    }
    for (int j = 0; j < nums.Length - 3; j++)
    {
        if (j > 0 && nums[j] == nums[j - 1])
        {
            continue;
        }
        int s_target = target - nums[j];
        for (int i = j+1; i < nums.Length - 2; i++)
        {
            if (i > j + 1 && nums[i] == nums[i - 1]) continue;
            int left = i + 1, right = nums.Length - 1;
            while (left < right)
            {
                if (nums[i] + nums[left] + nums[right] == s_target)
                {
                    result.Add(new List<int>() { nums[j], nums[i], nums[left], nums[right] });
                    left++;
                    right--;
                    while (left < right && nums[left] == nums[left - 1])
                    {
                        left++;
                    }
                    while (left < right && nums[right] == nums[right + 1])
                    {
                        right--;
                    }
                }
                else if (nums[i] + nums[left] + nums[right] > s_target)
                {
                    right--;
                }
                else
                {
                    left++;
                }
            }
        }
    }
    return result;
}

Remove Nth Node From End of List

Given a linked list, remove the n-th node from the end of list and return its head.
Example:
Given linked list: 1->2->3->4->5, and n = 2.
After removing the second node from the end, the linked list becomes 1->2->3->5.

给定一个链表和n值,需要移除链表中,从链表的最后端开始地n个值。
基本思路,通过对链表的一次完整遍历,找到链表中从末端开始第n个点上一个节点。

public class ListNode
 {
     public int val;
     public ListNode next;
     public ListNode(int x) { val = x; }
 }
static public ListNode RemoveNthFromEnd(ListNode head, int n)
  {
      ListNode cur_node = head;
      int index = 0;
      ListNode find_node_f = null;
      while (cur_node!= null)
      {
          index++;
          if ((index - n)>0)
          {
              if ((index - n) == 1)
              {
                  find_node_f = head;
              }
              else
              {
                  find_node_f = find_node_f.next;
              }
          }
          cur_node = cur_node.next;
      }
      if (index >= n)
      {
          if (find_node_f == null)
          {
              head = head.next;
          }
          else
          {
              find_node_f.next = find_node_f.next.next;
          }
      }
      else
      {
          return null;
      }
      return head;
  }

遍历过程如图所示:
在这里插入图片描述
Review

Tips&Share

  • 最近在尝试用 selenium 做一个工作上的小工具,使用的编程语言是 c#。在启动的时候会报错:Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (SessionNotCreated)。看错误信息,问题出在IE的安全级别。修改IE安全中的保护模式,就可以解决这个问题,修改方法(win7):在“控制面板”->“网络和Internet”->“管理浏览器加载项”->“安全”->“受限制站点” 把启用保护模式的勾去掉。
  • Selenium 执行js代码的函数是:((IJavaScriptExecutor)m_driver).ExecuteScript(“js代码”);
    看其他python下使用 selenium 的例子,python 中的这个函数可以用js文件名作为参数,在 c# 中ExecuteScript函数的参数只能是字符串,也就是js代码。我的解决方法是把js代码写在文件中,读取文件中的内容然后再通过 ExecuteScript 执行 js 代码。
  • selenium c# Actions 类在哪里
    参考网站:https://blog.csdn.net/hanqionglaaa/article/details/8995262
    可以看到:org.openqa.selenium.interactions.Actions
    using OpenQA.Selenium.Interactions;
  • [C#] 字符串的分割与截取(split or substring)
    https://blog.csdn.net/ftell/article/details/81739215
    字符串分割:
string data = "THExxQUICKxxBROWNxxFOX";
string[] xx = data.Split(new string[] { "xx" }, StringSplitOptions.None);
foreach (string item in xx)
    System.Console.Write(item + " ");
  • windowsform 禁止调整窗口大小
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 在form的属性中也能找到 FormBorderStyle 属性进行设置。
  • win10 关闭U盘自动打开,在左下角输入框搜索“自动播放”,把自动播放关掉就可以了,也可以单独设置“可移动驱动器”为“不执行操作”
  • 最近停了一周,后续会增加刷题量,要不然这一周的任务有点太糊拢。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
本火锅店点餐系统采用Java语言和Vue技术,框架采用SSM,搭配Mysql数据库,运行在Idea里,采用小程序模式。本火锅店点餐系统提供管理员、用户两种角色的服务。总的功能包括菜品的查询、菜品的购买、餐桌预定和订单管理。本系统可以帮助管理员更新菜品信息和管理订单信息,帮助用户实现在线的点餐方式,并可以实现餐桌预定。本系统采用成熟技术开发可以完成点餐管理的相关工作。 本系统的功能围绕用户、管理员两种权限设计。根据不同权限的不同需求设计出更符合用户要求的功能。本系统中管理员主要负责审核管理用户,发布分享新的菜品,审核用户的订餐信息和餐桌预定信息等,用户可以对需要的菜品进行购买、预定餐桌等。用户可以管理个人资料、查询菜品、在线点餐和预定餐桌、管理订单等,用户的个人资料是由管理员添加用户资料时产生,用户的订单内容由用户在购买菜品时产生,用户预定信息由用户在预定餐桌操作时产生。 本系统的功能设计为管理员、用户两部分。管理员为菜品管理、菜品分类管理、用户管理、订单管理等,用户的功能为查询菜品,在线点餐、预定餐桌、管理个人信息等。 管理员负责用户信息的删除和管理,用户的姓名和手机号都可以由管理员在此功能里看到。管理员可以对菜品的信息进行管理、审核。本功能可以实现菜品的定时更新和审核管理。本功能包括查询餐桌,也可以发布新的餐桌信息。管理员可以查询已预定的餐桌,并进行审核。管理员可以管理公告和系统的轮播图,可以安排活动。管理员可以对个人的资料进行修改和管理,管理员还可以在本功能里修改密码。管理员可以查询用户的订单,并完成菜品的安排。 当用户登录进系统后可以修改自己的资料,可以使自己信息的保持正确性。还可以修改密码。用户可以浏览所有的菜品,可以查看详细的菜品内容,也可以进行菜品的点餐。在本功能里用户可以进行点餐。用户可以浏览没有预定出去的餐桌,选择合适的餐桌可以进行预定。用户可以管理购物车里的菜品。用户可以管理自己的订单,在订单管理界面里也可以进行查询操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值