My HackerRank codes
charles-wangkai / hackerrank Goto Github PK
View Code? Open in Web Editor NEWMy HackerRank solutions
Home Page: https://www.hackerrank.com/goalboy
My HackerRank solutions
Home Page: https://www.hackerrank.com/goalboy
public static boolean isFibo(int valueToCheck, int previousValue, int currentValue) {
return currentValue > valueToCheck ? false : valueToCheck == currentValue ? true : isFibo(valueToCheck, currentValue, currentValue + previousValue);
}
Hello,
Did your "Truck Tour" problem solution passed all test cases? It seems may fail in many cases. If last petrol pump loads still causes fuel negative then where it should point?
In line 21 and line 22 in the main code of even tree,write u1-1 and vi-1 instead of ui and vi,since they are giving out of bounds exception.
adjacentLists[ui-1].add(vi-1); adjacentLists[vi-1].add(ui-1);
It can be like this:
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Map<String, String> name2phone = new HashMap<String, String>();
int n = sc.nextInt();
sc.nextLine();
for (int i = 0; i < n; i++) {
String name = sc.nextLine();
String phone = sc.nextLine();
name2phone.put(name, phone);
}
while (sc.hasNext()) {
String name = sc.nextLine();
if (name2phone.containsKey(name)) {
System.out.println(name + "=" + name2phone.get(name));
} else {
System.out.println("Not found");
}
}
sc.close();
}
}
Just need to do a little change. Thanks.
you can also use the swap case built-in function
most people don't know that its exist
def swap_case(s):
return s.swapcase()
if __name__ == '__main__':
s = input()
result = swap_case(s)
print(result)
happy coding
Hi @charles-wangkai, I hope you're doing well
If you have 10min, would you add a few comments for this solution?
https://github.com/charles-wangkai/hackerrank/blob/c418fb24e08e5c57a1bd0d91f95ab2af32f01c64/decibinary-numbers/Solution.java
I want to understand deeper buildF method and why do you use left-shift and why variable names are C, F, S?
PS:
(If you don't have time, just close this issue)
Sorry for this question and thank you!
File is invalid : wrong while submitting code.
`#!/bin/python3
import sys
import math
def encryption(s):
L = len(s)
r = math.floor(math.sqrt(L)) #2
c = math.ceil(math.sqrt(L)) #3
arr = []
n=0
for i in range(r):
a = []
for j in range(c):
if n < L:
a.append(s[n])
else:
break
n+=1
arr.append(a)
print(arr)
resStr = ''
for i in range(c):
for j in range(r):
try:
resStr += arr[j][i]
except IndexError:
break
resStr += ' '
return resStr
if name == "main":
s = input().strip()
result = encryption(s)
print(result)
`
Can you please provide explanation of truck tour problem in hackerrank....And it helped me to clear assessment...Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.