publicclassSolution{privatestaticStringoperate(boolean[][] arr,String op,inta,intb){switch(op) {case"AND":for(inti=0;i<arr[0].length;i++) { arr[a-1][i] = arr[a-1][i] & arr[b-1][i]; }break;case"OR":for(inti=0;i<arr[0].length;i++) { arr[a-1][i] = arr[a-1]...
hackerrank solutions java GitHub | hackerrank tutorial in java | hackerrank 30 days of code solutions | hackerrank algorithms solution | hackerrank cracking the coding interview solutions | hackerrank general programming solutions | hackerrank implementation solutions | hackerrank data structures solutions in ...
import java.util.Scanner; public class Solution { static boolean isAnagram(String a, String b) { boolean x= true; if (a.length()!=b.length()){ x=false; } a= a.toLowerCase(); b=b.toLowerCase(); int al[]=new int [256]; for(char c : a.toCharArray()){ int i=(int) c;...
for (int j = i; j < n; j++) { lengths[j] -= temp; } } } int[] res = new int[ans.size()]; for (int i = 0; i < ans.size(); i++) res[i] = ans.get(i); return res; } Prime or Not? 判断质数 返回最大因数 题目 是质数,返回1;不是质数,返回最大因数。 Solution ...
#TitleSolutionTimeSpaceDifficultyPointsNote Spaceholder C# O(1) O(1) Easy 1 Fundamentals#TitleSolutionTimeSpaceDifficultyPointsNote Leonardo's Prime Factors C# O(1) O(1) Easy 10 About HackerRank solutions in Java/JS/Python/C++/C# Resources Readme License MIT license Activity Stars 1 star...
// record how many comparisons the solution did; // it can be used to know which algorithm is better int comparisons = 0; for (int i = 0; i < size1; ++i) { for (int j = 0; j < size2; ++j) { // find longest length of prefix ...
INPUT Hello,hello ; expected output:anagram ; actual : not anagram; public static boolean isAnagram(String a,String b) { char a1[]=a.toCharArray(); char b1[]=b.toCharArray(); java.util.Arrays.sort(a1); java.util.Arrays.sort(b1);...
String:WelcometoHackerRank's Java tutorials!Double:3.1415Int:42 Hi, I don't understand why we have todo a sc.nextLine(), then do it again sc.nextLine()... Sometimes you have toclear the bufferto print the strings by command sc.nextLine(); ...
Time - Java - 12 H to 24 Hour Format (hackerrank, I was trying to solve some problems on hackerrank in Java 7 and I came across the time conversion problem where the problem statement is: Problem: "Given a time in -hour AM/PM format, convert it to military (24-hour) time." Sample...
Converting Java Time from 12-Hour to 24-Hour Format on HackerRank Solution 1: The reason for your code's failure is due to its mishandling of hour 12. Specifically,12:xx:xxAMneeds to correspond to00:xx:xx, while12:xx:xxPMneeds to correspond to12:xx:xx, as mentioned in Ole V.V.'...