您的位置 首页 golang

2022-01-10:路径交叉。给你一个整数数组 distance 。从 X-Y 平面上

2022-01-10:路径交叉。给你一个整数数组 distance 。

从 X-Y 平面上的点 (0,0) 开始,先向北移动 distance[0] 米,然后向西移动 distance[1] 米,向南移动 distance[2] 米,向东移动 distance[3] 米,持续移动。也就是说,每次移动后你的方位会发生逆时针变化。

判断你所经过的路径是否相交。如果相交,返回 true ;否则,返回 false 。

力扣335。

答案2022-01-10:

讨论4种情况。

1.i跟i-3撞。

2.i跟i-4撞,追尾。

3.i跟i-5撞。

4.i跟i-6撞。

代码用golang编写。代码如下:

 package main

import "fmt"

func main() {
    arr := []int{2, 2, 3, 2, 2}
    fmt.Println(isSelfCrossing(arr))
}

func isSelfCrossing(x []int) bool {
    if len(x) < 4 {
        return false
    }
    if (len(x) > 3 && x[2] <= x[0] && x[3] >= x[1]) || (len(x) > 4 && ((x[3] <= x[1] && x[4] >= x[2]) || (x[3] == x[1] && x[0]+x[4] >= x[2]))) {
        return true
    }
    for i := 5; i < len(x); i++ {
        if x[i-1] <= x[i-3] && ((x[i] >= x[i-2]) || (x[i-2] >= x[i-4] && x[i-5]+x[i-1] >= x[i-3] && x[i-4]+x[i] >= x[i-2])) {
            return true
        }
    }
    return false
}  

执行结果如下:

2022-01-10:路径交叉。给你一个整数数组 distance 。从 X-Y 平面上

***

[左神java代码](

文章来源:智云一二三科技

文章标题:2022-01-10:路径交叉。给你一个整数数组 distance 。从 X-Y 平面上

文章地址:https://www.zhihuclub.com/98338.shtml

关于作者: 智云科技

热门文章

评论已关闭

59条评论

  1. Similar trends were observed for male rabbits data not shown Anabolic androgenic steroids Medical assessment of present, past and potential users

  2. In yet another aspect, the invention provides kits for assessing the efficacy of a therapy for treating a sarcoma

  3. Your kindness and gentle manor was so very important It s not approved to treat early stage breast cancer but, according to Eli Lilly, the company recently filed for that approval

  4. Liquid chromatographic techniques used for such a purpose have gained inimitable importance in this process of drug analysis as a baseline for the determination of drugs, followed by its separation from the other interfering chemical entities that may be either metabolites and or IMPs

  5. 1995 Sep; 23 9 965 75 53, 54 Any potential bias associated with this assumption is therefore probably small

  6. The genes encoding enzymes involved in the conversion of the chorismate to menaquinone have been cloned in Esherichia coli 11 16, Bacillus subtilis 17 20, and Bacillus stearothermophilus 21 She asks you to begin with an affirmation an intention

  7. Endocrine relapse predicts a poor clinical outcome and remains an important target for future drug development

  8. Stefan LGFyHOTCTdSBQWYS 6 19 2022 Together, the principles of hierarchical organization comprising discrete classes and types as well as continuum within and across subpopulations represent a more nuanced and biologically realistic description of cell type landscape, with implications in cell classification and census

  9. Important information about DPYD mutations People with a mutation in the DPYD gene have a much higher risk of severe, sometimes life threatening, side effects from Xeloda

  10. Data about any drugs residents received in the 3 days prior to the assessment were collected from physician order sheets and drug administration records

  11. Flatulence is found among people who take Tamoxifen citrate, especially for people who are female, 60 old, have been taking the drug for

  12. 87 Many receptors possess intrinsic tyrosine kinase activity that is activated upon interaction of the receptor with its cognate ligand Relevant outcome measures included efficacy end points, AEs and measures of endoxifen concentrations

  13. According to the researching, learning how frogs hear could result in new advancements for hearing aids 2009; 9 631 643

  14. A mix of prescription medication and psychological therapy may help with short term relief which is also why the tamoxifen was contraindicated for me

  15. Pneumonol Alergol Pol 83 378 382 Supe says, so be more safe than sorry and avoid taking them if they re expired

  16. Around ages 16 18 y patients with FAP should be followed by annual or less frequent colonoscopic examinations depending on the polyp burden at last colonoscopy and all significant sized adenomas should be removed if surgery is not contemplated at that time

  17. Available results showed that AZD8055 possessed an acceptable toxicity profile, but no RECIST responses were seen 25

  18. Philadelphia PA AACR; Cancer Res 2016; 76 14 Suppl Abstract nr 3263 Tamoxifen was given at a dose of 40 mg daily for 2 years

  19. Tamarkin L, Cohen M, Roselle D, Reichert C, Lippman M, Chabner B 1981 Melatonin inhibition and pinealectomy enhancement of 7, 12 dimethylbenz a anthracene induced mammary tumors in the rat

  20. 8 in the women treated with metformin is similar to the rate of 10 15 reported for clinically recognized pregnancies in normal women 8, 9, suggesting that metformin treatment removed any independent risk for early pregnancy loss conferred by the disorder itself

  21. Therefore, it is reasoned that hypoxia would promote vascular endothelial cell migration toward CXCL12 and induce tumor vascularization in a CXCL12 dependent manner The two different treatment groups were compared about two outcome results CIBDAI and CRP serum level

  22. Side effects like hot flushes and hair thinning can be present, and would no doubt be much more severe in pre menopausal patients Endometriosis It is a condition in which non neoplastic endometrial glands or stroma is present outside of the endometrial cavity

  23. In that study, atorvastatin improved lipid profile, reduced CRP and improved insulin sensitivity 15

  24. uroxatral lupron medscape EBay Inc dropped 3 Typical sulfa allergy symptoms might be the following

  25. Case report The patient had allegedly taken a mixed overdose of 225mg of mirtazapine and unknown quantities of paracetamol, alcohol and veterinary furosemide sometime previously Increasing age has no effect on tolvaptan plasma concentrations

  26. In addition, the rate of decline of the serum calcium was slow, with the nadir calcium values occurring 8 10 days after the initiation of the gallium infusion

  27. Parachuted in from Down Under to help salvage something from a miserable league season, the 28 year old did not waste time making an impact 12 The diagnosis of SS is guided by the Sternbach criteria, listed in Table 2, although other less utilized diagnostic criteria exist

  28. avandia sandoz tamsulosin cr The public has a right to expect honesty and transparency from its ministers Also, what CD did the doctor run bloodwork

  29. Tamoxifen stock solution was prepared by dissolving 10 mg of Tamoxifen into 500 Вµl of absolute ethanol and then adding 4

  30. It affected most aspects of her life including being organized, multitasking, remembering details and phone numbers, and getting to places on time Herbert s advice is Then with alcohol, after embryo transfer or once you are pregnant, there is always a concern with fetal alcohol syndrome

  31. 16 conducted a study of CMF 5 years of tamoxifen versus CMF placebo versus adriamycin cytoxan AC tamoxifen compared with AC placebo

  32. Several small studies have suggested that information and support interventions improve adherence, lending credence to this possibility Why Take Steroids

  33. The active substance Stanozolol of Winstrol is bound by the androgen receptors located in the bone and muscle tissue of the body This pocketing can cause a sensation of pressure as well as a deep seated pain

  34. Under the terms of the settlement agreements, Upsher agreed not to market generic versions of K Dur until September 1, 2001, and granted Schering several licenses to make and sell certain Upsher products, including Niacor SR the parties subsequently abandoned plans to market Niacor SR

  35. Amongst the different vectors used, lentiviral vector constructs have proven very useful Harrow J, Frankish A, Gonzalez JM, Tapanari E, Diekhans M, Kokocinski F, et al

  36. There is insufficient information for many specific antioxidant supplements to determine if they are safe and effective as a complementary therapy to standard cancer treatment

  37. This is excessive and can potentially cause water retention, gynecomastia the formation of female breast tissue or benign prostatic hyperplasia

网站地图