Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cpp/first.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// C++ program to display "Hello World"

// Header file for input output functions
#include <iostream>
using namespace std;

// Main() function: where the execution of program begins
int main()
{
// prints hello world
cout << "Hello World";

return 0;
}
32 changes: 16 additions & 16 deletions java/70-climbing-stairs.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
class Solution {
public int climbStairs(int n) {
int dp[] = new int[n+1];
dp[n] = 1;
for(int i = n; i>=0; i--){
if(i+1<=n){
dp[i] = dp[i+1];
}
if(i+2<=n){
dp[i] = dp[i+1] + dp[i+2];
}
}
return dp[0];
}
class Solution {
public int climbStairs(int n) {

int dp[] = new int[n+1];
dp[n] = 1;
for(int i = n; i>=0; i--){
if(i+1<=n){
dp[i] = dp[i+1];
}
if(i+2<=n){
dp[i] = dp[i+1] + dp[i+2];
}
}

return dp[0];
}
}
34 changes: 34 additions & 0 deletions python/romantointger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Solution(object):
def romanToInt(self, s):
"""
:type s: str
:rtype: int
"""
roman_dic = {
"I": 1,
"V": 5,
"X": 10,
"L": 50,
"C": 100,
"D": 500,
"M": 1000,
}


skip_next_n = False
int_sum = 0
for idx, n in enumerate(s):
if skip_next_n == True:
skip_next_n = False
continue
try:
if roman_dic[n] < roman_dic[s[idx + 1]]:
int_sum += roman_dic[s[idx + 1]] - roman_dic[n]
skip_next_n = True
continue
else:
int_sum += roman_dic[n]
except:
int_sum += roman_dic[n]

return int_sum