Submission Details

本文介绍了一种二分查找法解决特定问题的高效算法,即在一个排好序且元素各不相同的数组中找到中间元素的下标。通过细致分析不同情况下的数组特性,我们能够快速定位目标值,简化搜索过程。

题目大意

这个题目出得很无聊,给你一个所谓的排好序的数组(比如说4 5 6 7 0 1 2 3),每个元素只出现一次,然后让你找中间一个值的下标,如果不存在返回-1

思路

二分查找,主要难点在二分范围的确定。
很显然,如果 nums[l]<=nums[mid]} 那么[l,mid]为递增序列

CODE

class Solution {
public:
    int search(vector<int>& nums, int target) {
        int l = 0, r = nums.size() - 1;
        while (l != r)
        {
            const int mid = (l + r) >> 1;
            if (nums[mid] == target)
            {
                return mid;
            }
            if (nums[l] <= nums[mid])
            {
                if (nums[l] <= target 
                    && target < nums[mid])
                {
                    r = mid;
                    continue;
                }
                l = mid + 1;
                continue;
            }
            if (nums[mid] < target
                && target <= nums[r])
            {
                l = mid + 1;
                continue;
            }
            r = mid;
        }
        if (nums[l] == target)
        {
            return l;
        }
        return -1;
    }
};
Lab 1: SQL injections detection and correction ZAP is a vulnerability analysis tool used to scan Web applications for possible software flaws. As an introduction to using ZAP, you will run the attack scanner on vulnerable code such as BWAPP, DAMN, and WebGoat. In this lab, we will run the automatic scanning feature of ZAP and discuss approaches to prioritize and mitigate four security vulnerabilities related to SQL injection found in each Web applications such as BWAPP, DAMN, and WebGoat. You should review the report carefully comparing the risk levels, descriptions, URL, Parameter, Attack, Solution, Reference CWE ID, etc. Typically, you should work to mitigate the higher risk issues first. After you have resolved the issues, you can rescan the application and see if any Alerts remain. The analysis and mitigation of issues is a repetitive process that should be done often in development and after each release to make sure issues are not introduced during updates. ZAP is just one tool for use in this process. Lab submission details: For this lab, you will provide a detailed analysis using both manual interception techniques and automatic scanner attacks. Be sure to provide screen captures of you running of the tool and analyze all files. When you run the automatic scan, be sure to generate an HTML report showing all alerts. For each alert, you need to describe how you prioritized alert messages. For your deliverables, you should submit a zip file containing your word document (or PDF file) with screen shots of your scans. Be sure to include the descriptions and analysis of your results, your prioritization and approach to mitigating the issues. Also, include the reports from your scan. Your report should be well-organized and clearly written. Evaluation: -Four SQL injections detections and corrections: 4 points -Report clarity and lab performing: 1 points这是我们的实验需求,解释需要我们做什么
最新发布
09-16
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值