Skip to main content

All Questions

2 votes
2 answers
861 views

LeetCode 3Sum Java Solution

I have this Java solution to LeetCode's 3Sum problem. I would be really grateful if I could get feedback on correctness, scalability, efficiency, coding best practices, and OOP design. I'm relatively ...
StackMatch's user avatar
5 votes
4 answers
552 views

LeetCode: Roman to Integer in Java

I tried solve this easy leetcode challenge in java. Challenge link Here is my solution ...
srk's user avatar
  • 618
1 vote
3 answers
480 views

Transpose 2D Matrix in Java - Time & Space Complexity?

Here's my algorithm / approach for transposing a 2D Matrix on the main diagonal. Before: a L M d b G c N H K e F I J O P After: ...
PacificNW_Lover's user avatar
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
3 votes
1 answer
3k views

Circuit builder that calculates resistance/current/voltage

I am somewhat new to programming. I've written a program that takes user input accepting voltages and resistors, and calculating total resistance/current/voltage in the circuit. I am looking for ways ...
Michael Sinclair's user avatar
0 votes
1 answer
82 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
1 vote
1 answer
688 views

Find maximum in sorted and rotated array

This is an interview question. A sorted rotated array is a sorted array which was rotated 0 or more times. For example: [1,2,3] -> [2,3,1] ...
Rodrigo's user avatar
  • 21
2 votes
1 answer
721 views

Max Increase to Keep City Skyline in Java

In a 2-dimensional array grid, each value grid[i][j] represents the height of a building located there. We are allowed to increase the height of any number of buildings, by any amount (the amounts can ...
Anirudh Thatipelli's user avatar
2 votes
1 answer
1k views

Return the optimal time slot

Implement a function meetingPlanner that given the availability, slotsA and slotsB, of two people and a meeting duration dur, returns the earliest time slot that works for both of them and is of ...
Anirudh Thatipelli's user avatar
3 votes
3 answers
4k views

Return the anti-diagonals

Give a N*N square matrix, return an array of its anti-diagonals. Look at the example for more details. Example: Input: ...
Anirudh Thatipelli's user avatar
4 votes
5 answers
3k views

Find The Duplicates in two arrays

Find The Duplicates Given two sorted arrays arr1 and arr2 of passport numbers, implement a function findDuplicates that returns an array of all passport numbers that are both in arr1 and arr2. Note ...
Anirudh Thatipelli's user avatar
4 votes
2 answers
640 views

Find lexicographical permutations

I have tried many possible methods here but I am still not able to reduce the time complexity of below algorithm. The basic layout of my problem is as follows: I have a string that is composed of ...
CodeHunter's user avatar
5 votes
2 answers
8k views

Find the number of K-Complementary pairs in an array

Below is the program to find k-complementary pairs: K = A[i] + A[j];. ...
SiddP's user avatar
  • 153
2 votes
2 answers
1k views

Determining if two strings are anagrams

Two strings are said to be anagrams of each other if the letters of one string may be rearranged to make the other string. For example, the words 'elvis' and 'lives' are anagrams. In this ...
Ankur Anand's user avatar
7 votes
5 answers
17k views

Finding the most common character in a string with a hash map

I created a method for finding the most common character in a string (using HashMap): ...
Roey Cohen's user avatar

15 30 50 per page