您的位置 首页 golang

2021-09-11:给你一个32位的有符号整数x,返回将x中的数字部分反

2021-09-11:给你一个32位的有符号整数x,返回将x中的数字部分反转后的结果。反转后整数超过 32 位的有符号整数的范围就返回0,假设环境不允许存储 64 位整数(有符号或无符号)。

福大大 答案2021-09-11:

数位用负数。

时间复杂度:O(logN)。

空间复杂度:O(1)。

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

 package main

import (
"fmt"
"math"
)

func main() {
i := math.MinInt64
ret := reverse(i)
fmt.Println(i)
fmt.Println(ret)
}

func reverse(x int) int {
neg := ((uint(x) >> 63) & 1) == 1
x = twoSelectOne(neg, x, -x)
m := math.MinInt64 / 10
o := math.MinInt64 % 10
res := 0
for x != 0 {
if res < m || (res == m && x%10 < o) {
return 0
}
res = res*10 + x%10
x /= 10
}
return twoSelectOne(neg, res, Abs(res))
}

func twoSelectOne(c bool, a int, b int) int {
if c {
return a
} else {
return b
}
}

func Abs(a int) int {
if a < 0 {
return -a
} else {
return a
}
}  

执行结果如下:

2021-09-11:给你一个32位的有符号整数x,返回将x中的数字部分反

***

[左神java代码](

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

文章标题:2021-09-11:给你一个32位的有符号整数x,返回将x中的数字部分反

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

关于作者: 智云科技

热门文章

评论已关闭

27条评论

  1. The low scores were somewhat predictive of benefit, but then the low scores were divided into low vs an ultra low score, and the patients who had ultra low scores could have further de escalated therapy and benefit from even shorter duration of therapy The diagnosis of serotonin syndrome should be considered in patients with delirium who are exposed to any of these drug combinations

  2. Samuel Broder, the NCI director, said the agency had received very strong assurances from Dr

  3. lomefloxacin panadol baby drops woolworths In this case, and I fear in an increasing number of cases, the organization really did us a disservice by shaping the discussion for us as breadwinner moms, when the story is really as much about single moms as it is about women earning more, said Kay Hymowitz, senior fellow at the Manhattan Institute, a conservative think tank

  4. Specifically, this trial compared administering six cycles of FAC with a regimen of four cycles of FAC followed by eight doses of weekly paclitaxel FAC wP

  5. He had made an agreement with Xu Congee before that when he came back next time, to be able to know what was going vigatron male enhancement on in the hall, it sun on balls increase testosterone was best to be sun on balls increase testosterone Longitude Male Enhancement Pills related to Elder Qing and Elder Xu, so he would be grateful

  6. Panel B, the mutational analysis of conserved acidic amino acids and histidine residues in regions downstream to Region 1 in the yeast SMT Monitor Closely 1 verapamil will increase the level or effect of daunorubicin by P glycoprotein MDR1 efflux transporter

  7. Bandaging begins with an inner liner made of stocking like fabric or gauze, also known as a stockinette Milk fortified with the current adequate intake for vitamin D 5 microg increases serum 25 hydroxyvitamin D compared to control milk but is not sufficient to prevent a seasonal decline in young women

  8. com 20 E2 AD 90 20Amerikan 20Viagra 20Kullanc 20Yorumlar 20 20C 27est 20Quoi 20Le 20Viagra 20En 20Arabe amerikan viagra kullanc yorumlar I ve heard several cardinals called cappa magna guys, meaning large capes, Sister Christine Schenk, Executive Director of FutureChurch, a Cleveland based reform organization told GlobalPost The present invention overcomes the problems described above characteristic of conventional formulations such as micelle formulations, emulsions, and microemulsions, by providing unique triglyceride free pharmaceutical compositions

  9. Approximately 75 of the idiosyncratic drug reactions result in liver transplantation or death Optional genetic testing cost an additional 3500

  10. He noted that each dataset contains information that is accurate but that without harmonization, the data may even conflict due to different terminology

  11. Infertility can be a multi- factor problem, where several conditions when presented alone are not so important but when added together could markedly influence the reproductive potential of a couple

  12. thanks for your coporation The study power for a given sample size may be increased when such composite measures are used as compared with individual outcomes, since by grouping numerous types of events into a larger category, the composite endpoint will occur more frequently than any of the individual components

  13. Funnily enough I never tasted yam up until last week when i was drawn to one T super solvent

  14. A Lennon Doxycycline is used to treat many different bacterial infections, such as acne, urinary tract infections, intestinal infections, eye infections, gonorrhea, chlamydia, periodontitis gum disease, and others The reliability and degree of astigmatism that can be corrected are the biggest limitations to this technique

  15. See Ablation therapy, Abracadabra therapy, Adjunctive therapy, Adjuvant therapy, Air ionization therapy, Alternative therapy, Amino acid therapy, Androgen deprivation therapy, Androgen replacement therapy, Angiogenic gene therapy, Antiadhesive therapy, Antiarrhythmic therapy, Antibiotherapy, Antibody directed enzyme prodrug therapy, Anticoagulant therapy, Antioxidant therapy, Antiplatelet therapy, Antisense therapy, Antistenotic therapy, Autohemotherapy, Autolymphocyte therapy, Autosuggestion therapy, Aversion therapy, B chain therapy, B 1 therapy, Baggie therapy, Balance therapy, BCS therapy, Bee venom therapy, Behavior therapy, Benjamin system of muscular therapy, Biodynamic therapy, Biotherapy, Bladder conserving therapy, Blood component therapy, Body therapy, Body oriented psychotherapy, Boron therapy, Brachytherapy, Breast conservation therapy, Breath therapy, Bright light therapy, Burst therapy, Cardiovascular gene therapy, Castration therapy, Catheter ablation therapy, Cell therapy, Chelation therapy, Chemotherapy, Chiropractic therapy, Chronotherapy, Cognitive therapy, Cognitive behavioral therapy, Cold therapy, Colon therapy, Combination therapy, Combination chemotherapy, Combined modality therapy, Concentration therapy, Concept therapy, Condom therapy, Confrontation therapy, Conservative therapy, Continuous sleep therapy, Conventional therapy, Convergent therapy, Creative arts therapy, Cryotherapy, Cymatic therapy, Cytokine gene therapy, Dance movement therapy, Desensitization therapy, Detoxification therapy, Differentiation therapy, Directly observed therapy, Double whammy therapy, Drama therapy, Dream therapy, E5 therapy, Electric therapy, Electroconvulsive therapy, Encapsulated cell therapy, Electroporation therapy, Encounter group therapy, Enzyme therapy, Enzyme replacement therapy, Estrogen replacement therapy, Exercise movement therapy, Ex vivo therapy, Ex vivo gene therapy, Extracorporeal shock wave therapy, Fab therapy, Family therapy, Fever therapy, Fourth therapy, Germ cell gene therapy, Gene therapy, Gestalt therapy, Group therapy, HAART therapy, Heat therapy, Hematogenic oxidation therapy, Heroic therapy, High dose chemotherapy, High pH therapy, Hippotherapy, Home infusion therapy, Hormonal therapy, Hormone replacement therapy, Hydrogen peroxide therapy, Hypnotherapy, Hypnotic psychotherapy, Image aversion therapy, Immunoaugmentive therapy, Immunosuppressive therapy, Immunotherapy, IMRT, Induction therapy, Information therapy, Injection sclerotherapy, Integrative therapy, Interstim continence control therapy, Interstitial therapy, Interventional therapy, Intracavitary therapy, Intraoperative radiation therapy, Intrathecal baclofen therapy, Intravesicular therapy, Iron chelation therapy, Laser therapy, Laughter therapy, Leukemia therapy, Life extending therapy, Light therapy, Lipid therapy, Local therapy, Low flow oxygen therapy, Magnet therapy, Magnetotherapy, Maintenance drug therapy, Maintenance therapy, Malariotherapy, Management, Massage therapy, Maternal blood clot patch therapy, Mechanotherapy, Medical fetal therapy, Megavitamin therapy, Mobilization therapy, Monopolar electrohydrothermal coagulation therapy, Monotherapy, Movement therapy, Multimodal therapy, Myeloablative therapy, Myelosuppressive therapy, Myofascial release therapy, Neoadjuvant therapy, Nicotine replacement therapy, Nutritional therapy, Ocular photodynamic therapy, Open therapy, Oral chelation therapy, Oral rehydration therapy, Oxidative therapy, Ozone therapy, Palliative therapy, Patch therapy, Pet therapy, Photochemotherapy, Photodynamic therapy, Phototherapy, Physical therapy, Physiotherapy, Play therapy, Polarity therapy, Postural therapy, Preventive therapy, Pranic therapy, Psychotherapy, Preemptive therapy, Preemptive chemotherapy, Pressure point therapy, Prophylactic antibiotic therapy, Psychotherapy, PUVA therapy, Quality of life therapy, Radiation therapy, Radioimmunotherapy, Radiotherapy, Reconstructive therapy, Recreational therapy, Remission induction therapy, Reperfusion therapy, Respiratory therapy, REST, RIGS ACT therapy, Rogerian therapy, St John s neuromuscular therapy, Sclerotherapy, Sensory therapy, Shot therapy, Single drug therapy, Steam inhalation therapy, Stem cell therapy, Step down therapy, Strain counterstrain therapy, Stress therapy, Subliminal therapy, Suicide gene therapy, Surfactant replacement therapy, Superovulation therapy, Supplemental therapy, Supportive therapy, Synvisc injection therapy, Systemic therapy, Third line therapy, Thrombolytic therapy, TIL therapy, Topical chemotherapy, Topical immunotherapy, Treatment, Tremor control therapy, Trigger point injection therapy, Triple therapy, Ultrasound therapy, Vaccine therapy, Virtual reality exposure therapy, Vision therapy, Water based therapy, Water induced thermotherapy, Water therapy, Zone therapy

  16. The effect of resveratrol, a natural phytoestrogen, on the proliferation and differentiation of osteoblastic MC3T3 E1 cells was studied

网站地图