Skip to content

Instantly share code, notes, and snippets.

View codeperfectplus's full-sized avatar
🟢
Online

Deepak Raj codeperfectplus

🟢
Online
View GitHub Profile
def twoSum(self, nums: List[int], target: int) -> List[int]:
seen = {}
for index, num in enumerate(nums):
other = target - num
if other in seen:
return[seen[other],index]
else:
seen[num] = index
def multiples(n):
sum = 0
for i in range(n):
if(i%3==0) or (i%5==0):
sum += i
return sum
print(multiples(1000))
#include <iostream>
#include <iomanip>
#include <limits>
using namespace std;
int main() {
int i = 4;
double d = 4.0;
string s = "HackerRank ";
i2 = int(input())
d2 = float(input())
s2 = input()
print(i + i2)
print(d + d2)
print(s + s2)
// Declare second integer, double, and String variables.
// Read and save an integer, double, and String to your variables.
var i2 = +(readLine());
var d2 = +(readLine());
var s2 = readLine();
// Print the sum of both integer variables on a new line.
console.log(i + i2);
// Print the sum of the double variables on a new line.
/**
* Calculate the area of a rectangle.
*
* length: The length of the rectangle.
* width: The width of the rectangle.
*
* Return a number denoting the rectangle's area.
**/
function getArea(length, width) {
let area;
/*
* Create the function factorial here
* Recursion: To call itself is called recursion.
*/
function factorial(n) {
if (n === 0) {
return 1;
}
return n * factorial(n - 1);
}
function main() {
// Write your code here. Read input using 'readLine()' and print output using 'console.log()'.
let r = readLine();
const PI = Math.PI;
// Print the area of the circle:
console.log(PI * (r * r) );
// Print the perimeter of the circle:
console.log(2 * PI * r);
}
function getGrade(score) {
let grade;
// Write your code here
if(score<=5) {
grade="F";
}else if(score<=10) {
grade='E';
}else if(score<=15) {
grade='D'
}else if(score<=20) {
function getLetter(s) {
let letter;
// Write your code here
switch (true) {
case 'aeiou'.includes(s[0]):
letter = 'A';
break;
case 'bcdfg'.includes(s[0]):
letter = 'B';
break;