Skip to main content

All Questions

Filter by
Sorted by
Tagged with
5 votes
4 answers
516 views

Count number of substrings in less time

Given an input string contains letters from 'a' to 'g' Count how many substrings are there in the input string such that frequency of any character inside the substring is not more than the number of ...
CodeCrusader's user avatar
13 votes
5 answers
2k views

solve n*m matrix processing in less time

I want to solve a problem in less time complexity. Here are the details: Given an n*m matrix, n rows and m columns. Initially, the matrix is empty filled with 0s. ...
CodeCrusader's user avatar
3 votes
1 answer
128 views

Substring search in Java

I am trying to make an algorithm that will find the index of a given substring (which I have labeled pattern) in a given String (...
qwerty's user avatar
  • 361
4 votes
2 answers
2k views

Time and Space Complexity of Prime factorization

I have written a function that prints all the prime factors for a given number. Here is my code ...
srk's user avatar
  • 628
0 votes
2 answers
620 views

Java Palindrome - Time & Space Complexity

Which of these three methods is the most efficient? Also, what is the time & space complexity of each? ...
PacificNW_Lover's user avatar
9 votes
3 answers
4k views

Find the smallest positive integer that is absent from a given array

I made the acquaintance of big-O a couple of weeks ago and am trying to get to grips with it, but although there's a lot of material out there about calculating time complexity, I can't seem to find ...
half of a glazier's user avatar
2 votes
1 answer
110 views

Find the number of all specific substrings in a string

I would like to ask a code review regarding a concrete exercise. Let's suppose I have to get the number of all specific substrings in a string. We call something specific if any of these conditions ...
Csongi Nagy's user avatar
2 votes
1 answer
188 views

Kruskal MST algorithm

I came up with the following code by following Prof. Sedgewick's lecture on Coursera. Please review this code and let me know if there is anything that I got wrong in implementing Kruskal's ...
bp4D's user avatar
  • 131
6 votes
1 answer
325 views

Phonebook using a trie

I implemented a PhoneBook utilizing a Trie data structure. Could I ask you to evaluate it? Did I apply Trie correctly for such ...
Pavel's user avatar
  • 218
0 votes
1 answer
90 views

Searching for a sum of any series in array

I'm given this method, and requested to analyze what it does, and minimize its complexity (both time and space). All values are known to be larger than zero. ...
Shimmy Weitzhandler's user avatar
2 votes
2 answers
293 views

Substrings search (Aho-Corasick algorithm)

I have a code where the goal is to give score to strings based on how much score certain substrings are worth (including repeating substrings). The way my code (which is based on the Aho-Corasick ...
potato's user avatar
  • 1,122
3 votes
1 answer
6k views

"Counter Game" Powers of 2 Game

I have been working on this hackerrank problem: Louise and Richard have developed a numbers game. They pick a number (1 ≤ n < 264) and check to see if it is a power of 2. If it is, they divide ...
Benjamin Patch's user avatar
3 votes
2 answers
104 views

Place arithmetic signs in correct order to get the number

Given a list of numbers, place signs + or - in order to get the required number. If it's possible then return ...
stfedosov's user avatar
  • 141
-3 votes
1 answer
104 views

Given an array of positive integers, find shortest subarray whose sum exceeds a threshold [closed]

Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't one, return 0 instead. Example: Input: ...
user182009's user avatar
-2 votes
1 answer
109 views

Leet Code :: Merge Binary Tree :: Time Complexity [closed]

Problem Statement: Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into ...
Abhiroj Panwar's user avatar

15 30 50 per page