Given a binary tree containing digits from 0⑼ only, each root-to-leaf path could represent a number.
An example is the root-to-leaf path 1->2->3 which represents the number 123.
Find the total sum of all root-to-leaf numbers.
For example,
1
/
2 3
The root-to-leaf path 1->2 represents the number 12.
The root-to-leaf path 1->3 represents the number 13.
Return the sum = 12 + 13 = 25.
这个题目很简单,可用递归做:
public:
int sumNumbers(TreeNode *root) {
sum = 0;
sumNumbers(root, 0);
return sum;
}
private:
int sum;
void sumNumbers(TreeNode *root, int num) {
if (!root) return;
num = num*10 + root->val;
if (root->left == nullptr && root->right == nullptr) sum += num;
if (root->left) sumNumbers(root->left, num);
if (root->right) sumNumbers(root->right, num);
}
};
波比源码 » LeetCode[Tree]: Sum Root to Leaf Numbers
levofloxacin online buy buy generic levaquin 250mg
order dutasteride sale flomax order online zofran buy online
order aldactone 100mg pills purchase propecia sale fluconazole generic
buy ampicillin for sale sulfamethoxazole over the counter erythromycin 250mg tablet
sildenafil pills robaxin oral order methocarbamol without prescription
suhagra over the counter buy suhagra 50mg pills order generic estradiol
order lamictal 50mg pill lamictal 50mg pills buy retin
tadalis 20mg cheap buy tadalafil online purchase voltaren without prescription
order isotretinoin 20mg for sale order isotretinoin generic cheap zithromax
order anastrozole 1 mg online cheap buy biaxin online buy sildenafil for sale
vrai tadalafil 5mg prix viagra en ligne viagra 25mg prix
cialis 5mg kaufen tadalafil kaufen viagra fГјr frauen
doxycycline buy online levitra cheap order lasix 100mg
buy fosamax 35mg pill fosamax 70mg canada famotidine 40mg usa
buy prograf online cheap trandate online buy urso buy online
purchase isosorbide sale buy azathioprine online telmisartan pills
purchase bupropion online cheap purchase zyban for sale quetiapine 100mg pills
order molnunat pill molnupiravir online lansoprazole 15mg uk
zoloft usa order kamagra pill sildenafil drug
imuran 100mcg drug purchase imuran pill generic viagra 50mg
order revia 50mg order revia without prescription abilify cheap
oral provera 5mg buy medroxyprogesterone 10mg pills oral periactin 4mg
order provigil 200mg online best rated canadian online pharmacy stromectol pills
buy generic luvox 100mg order glipizide 5mg sale glipizide cost
nootropil 800 mg pills viagra 100mg canada sildenafil online
cialis 20mg cheap guaranteed cialis overnight delivery usa sildenafil 50mg pill
buy generic furosemide 40mg lasix 100mg us order plaquenil
purchase chloroquine pill order baricitinib order olumiant pill
order metformin 1000mg online order atorvastatin 10mg online cheap buy tadalafil 20mg online
order zyprexa 10mg sale olanzapine 10mg tablet purchase valsartan generic
order omeprazole 20mg generic buy omeprazole 10mg sale slot games online free
zyvox 600mg cheap real casino slots slots games free
purchase essays online roulette online real money real casino games
clomid order order ventolin inhalator generic online casino for real money
aristocort drug aristocort canada clarinex 5mg canada
buy priligy 30mg generic purchase dapoxetine generic order synthroid sale
cialis 40mg cost generic sildenafil 100mg viagra next day delivery
order orlistat 120mg sale orlistat 120mg without prescription order generic zovirax
allopurinol 300mg pill allopurinol for sale online buy ezetimibe
order generic methotrexate 10mg cheap reglan 20mg order reglan generic
oral gloperba buy colchicine 0.5mg online online slots real money
ranitidine 300mg ca celecoxib 200mg canada celebrex canada
best online gambling sites hollywood casino online slots
simvastatin pills simvastatin 10mg cost order proscar 5mg pill
cephalexin online buy cephalexin 125mg for sale order erythromycin 250mg generic
generic cialis 20mg viagra 100mg sale buy sildenafil 50mg generic
online casino slots no download slots games free purchase cialis sale
desyrel 50mg for sale sildenafil online oral aurogra 50mg
essay edit best essay service ivermectin cost australia
sildalis oral lamictal online order lamotrigine drug
deltasone 5mg without prescription order accutane 20mg online cheap order amoxil 500mg sale
buy viagra 50mg without prescription sildenafil 100mg pill order cialis 5mg without prescription
buy azithromycin generic order neurontin without prescription order neurontin 100mg sale
retin brand avanafil medication order avana 100mg for sale
cost tadacip 20mg diclofenac 100mg price indomethacin 75mg cheap
buy naprosyn 500mg online omnicef order online oral lansoprazole
buy proventil 100 mcg generic order proventil 100mcg online cheap cipro for sale online
cialis 5mg us order tadalafil 5mg online tadalafil ca
stromectol 6 mg dosage stromectol 12mg cost generic dapsone 100mg
doxycycline tablet order doxycycline without prescription cleocin cost
asacol order online azelastine cost cheap avapro 150mg
olmesartan buy online olmesartan cost depakote 500mg ca
buy acetazolamide pill azathioprine without prescription order imuran generic
temovate buy online buspar pills cheap cordarone
oral alendronate 35mg nitrofurantoin 100mg generic order motrin 400mg online cheap
order famotidine 20mg without prescription buy prograf pills mirtazapine 30mg pills
tricor 160mg usa order viagra for sale cheap sildenafil sale
brand cialis buy ed pills gb ed pills no prescription
order clomiphene generic buy prednisolone 10mg pills purchase prednisolone online
modafinil tablet generic zestril metoprolol pills
vibra-tabs pills cheap zovirax 800mg buy zovirax 400mg online cheap
buy ditropan 2.5mg online cheap order ditropan 2.5mg generic buy oxcarbazepine 300mg generic
cefdinir 300mg pill generic cefdinir 300mg buy protonix 20mg without prescription
buy dapsone online purchase tenormin generic order generic atenolol 50mg
order levaquin 250mg ursodiol for sale online buy zyban generic
order cetirizine 5mg pills zyrtec 5mg pill buy zoloft pills for sale
escitalopram 10mg canada revia online buy revia online order
buy atorvastatin 10mg generic oral sildenafil 100mg buy viagra 100mg without prescription
buy oral ivermectin order accutane 10mg generic buy accutane 10mg generic
brand amoxicillin 1000mg prednisolone canada prednisolone 10mg cost
isotretinoin online buy zithromax 250mg generic buy azithromycin pills for sale
gabapentin 100mg canada gabapentin 100mg drug order doxycycline 200mg pills
buy clomid pill plaquenil cost buy generic hydroxychloroquine
buy atenolol 100mg generic order atenolol online femara 2.5 mg cheap
albenza pills albenza 400 mg cheap order medroxyprogesterone 5mg without prescription
buy glucophage 500mg online glycomet medication amlodipine 10mg uk
buy lisinopril 5mg for sale buy generic omeprazole over the counter lopressor usa
lyrica 75mg tablet purchase pregabalin without prescription purchase dapoxetine
xenical 120mg tablet zyloprim 300mg ca zyloprim 300mg drug
order rosuvastatin 10mg without prescription domperidone buy online order motilium 10mg generic
order toradol 10mg buy colchicine paypal inderal pills
ranitidine 300mg tablet purchase meloxicam pills celecoxib buy online
order generic flomax 0.4mg zofran 8mg for sale buy spironolactone generic
buy generic betamethasone over the counter betnovate 20 gm cost itraconazole 100mg pills
generic ipratropium 100 mcg linezolid canada buy zyvox 600mg generic
generic prometrium tindamax 300mg for sale cheap zyprexa
buy nateglinide 120mg captopril price order candesartan 16mg online
brand bystolic 20mg buy bystolic tablets buy cheap generic clozaril
zocor pills cost simvastatin sildenafil 100mg over the counter
tegretol 200mg sale order ciplox generic lincocin 500 mg tablet
cialis black tadalafil for sale buy viagra 100mg sale
oral diflucan 100mg buy generic cipro online buy cheap cipro
clindamycin without prescription fildena usa buy erection pills
order avana 200mg online cheap purchase tadalafil online cheap voltaren medication
buy indomethacin 75mg sale order terbinafine without prescription suprax 100mg ca
purchase bimatoprost online buy careprost generic buy trazodone without a prescription
buy minocin paypal order minocin pills buy pioglitazone 15mg
purchase leflunomide azulfidine 500mg canada buy sulfasalazine 500 mg pill
price of cialis order cialis 40mg cost tadalafil 40mg
stromectol how much it cost order stromectol pills deltasone 5mg generic
buy furosemide online diuretic order generic lasix ventolin 4mg ca
order altace 10mg ramipril pills order arcoxia online
mesalamine cheap astelin 10 ml usa irbesartan 150mg canada
lanoxin brand order micardis online cheap buy cheap molnupiravir
naprosyn 500mg tablet buy naprosyn 250mg online cheap order lansoprazole without prescription
albuterol pills proventil pills order pyridium 200mg pills
buy norvasc generic amlodipine medication omeprazole drug
buy lopressor 50mg generic atenolol 100mg ca methylprednisolone 8mg tablets
dapoxetine for sale buy misoprostol 200mcg without prescription brand xenical 60mg
diltiazem over the counter zovirax usa buy generic zyloprim 300mg
rosuvastatin uk rosuvastatin usa motilium where to buy
buy generic tetracycline buy sumycin online buy generic ozobax online
buy ketorolac generic how to buy colcrys brand inderal 20mg
purchase clopidogrel generic plavix pill warfarin 5mg canada
order rhinocort for sale how to buy bimatoprost careprost for sale online
topamax 200mg uk topamax 200mg cheap buy levofloxacin online cheap
lamotrigine for sale online purchase prazosin online cheap buy prazosin 2mg sale
celebrex 200mg price buy flomax 0.4mg without prescription ondansetron price
cost aldactone brand simvastatin valacyclovir 1000mg for sale
propecia online buy order viagra 50mg without prescription viagra ca
cheap tadalafil without prescription canadian cialis online pharmacy sildenafil 50mg price
terbinafine 250mg cheap buy cefixime no prescription order trimox 250mg online cheap
where to buy sulfasalazine without a prescription calan for sale calan 240mg for sale
order molnupiravir pill cefdinir 300mg generic cefdinir over the counter
erection pills that work tadalafil 5mg pills order cialis 5mg online
phenazopyridine 200mg pill phenazopyridine 200mg us symmetrel 100mg tablet
buy terazosin sale buy terazosin sale brand cialis 20mg
allegra 180mg over the counter order allegra 180mg pill glimepiride drug
cost etoricoxib 60mg order astelin 10 ml sprayers astelin 10 ml ca
generic irbesartan 300mg buy avapro 150mg order buspar 5mg online cheap
buy albenza generic medroxyprogesterone order cheap provera
praziquantel brand biltricide medication buy periactin 4mg
buy fluvoxamine 50mg sale buy fluvoxamine pills for sale duloxetine 20mg us
generic glucotrol 5mg nootropil order betnovate 20 gm brand
buy anafranil online cheap anafranil over the counter cheap progesterone 200mg
buy generic valsartan valsartan medication buy ipratropium medication
cost decadron buy dexamethasone no prescription nateglinide usa
cost captopril 25mg how to get nateglinide without a prescription tegretol 400mg cheap
purchase ciprofloxacin for sale lincomycin 500mg brand duricef 500mg us
buy epivir sale order zidovudine 300 mg generic quinapril 10 mg cost