Skip to content

Commit e354302

Browse files
committed
add two some leetcode ploblem solve
1 parent 66d3c1d commit e354302

2 files changed

Lines changed: 44 additions & 24 deletions

File tree

Programs/QuizGame.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
print("Welcome to my computer quize!")
2+
3+
playing = input("Do you want to play? ")
4+
5+
if playing.lower() != "yes":
6+
quit()
7+
else:
8+
print("Ok, let's play!")
9+
score = 0
10+
11+
answer = input("What dose CPU stand for? ")
12+
if answer.lower() == "central processing unit" :
13+
print("Correct")
14+
score += 1
15+
else:
16+
print("Incorrct")
17+
18+
19+
print("Your score is " + str(score))
20+
print("END")

Programs/TwoSum.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
55
// You can return the answer in any order.
66

7-
7+
88

99
// Example 1:
1010
// Input: nums = [2,7,11,15], target = 9
@@ -19,31 +19,31 @@
1919
// Input: nums = [3,3], target = 6
2020
// Output: [0,1]
2121

22-
22+
2323

2424
for (var i = 0; i < nums.length; i++) {
25-
for (var n = 1; n < nums.length; n++) {
26-
27-
if(nums[i] + nums[n] == target){
28-
if( nums[i]==nums[n] && nums.indexOf(nums[i]) == nums.indexOf(nums[n]) ){
29-
30-
let p = nums.indexOf(nums[n])+1
31-
32-
for (var m = p; m < nums.length; m++) {
33-
34-
if(nums[i]==nums[m]){
35-
return [i, m]
36-
}
37-
38-
}
39-
40-
}else{
41-
return([ nums.indexOf(nums[i]), nums.indexOf(nums[n]) ])
42-
25+
for (var n = 1; n < nums.length; n++) {
26+
27+
if (nums[i] + nums[n] == target) {
28+
if (nums[i] == nums[n] && nums.indexOf(nums[i]) == nums.indexOf(nums[n])) {
29+
30+
let p = nums.indexOf(nums[n]) + 1
31+
32+
for (var m = p; m < nums.length; m++) {
33+
34+
if (nums[i] == nums[m]) {
35+
return [i, m]
36+
}
37+
4338
}
44-
39+
40+
} else {
41+
return ([nums.indexOf(nums[i]), nums.indexOf(nums[n])])
42+
4543
}
46-
44+
4745
}
48-
49-
}
46+
47+
}
48+
49+
}

0 commit comments

Comments
 (0)