Time complexity of typecasting double to int in Java
double val = 500.00; int val2 = (int) val; What is the time complexity of typecasting in the previous example? Is it O(1)?
Online Free Tutorials Guruji Guide & Materials – Solved Questions Answers
double val = 500.00; int val2 = (int) val; What is the time complexity of typecasting in the previous example? Is it O(1)?
The question is to find the number of consecutive occurrences of a character ‘*’ in a string. I’ve written a program for it but is there any other efficient way to solve this for(int i=0;i<...
The question was to check whether two strings are rotation of each other or not. So, here is the function I wrote for the same: bool areRotations(string s1, string s2) { int n1 = …
Suppose I have the following code fragment: for(int i=0; i < n.length(); i++) { int aux = n[i]; if(map.containsKey(aux)) { map.put(aux, map.get(aux)+1); } else { map.put(...
I’ve beern trying to solve this question but getting timeout for most test cases. Can anyone help me in optimising this? Problem Statement : You are given an array A of length N. You have to choose …
A look-up operation OR contains for single can be O(n) in worst-case right ? So, for n elements look up in hashSet will be O(n^2)?