Skip to main content
The 2025 Developer Survey results are in. Explore insights into technology and tools, careers, community and more. View results.

All Questions

Filter by
Sorted by
Tagged with
1 vote
1 answer
94 views

Reverse a sublist of a singly-linked master list in constant space and maximum of one pass (Java)

So I found this funky programming challenge somewhere on Quora. The idea is to take the head of a singly-linked list, and reverse a specific sublist. The requirements are: runs in constant space, ...
coderodde's user avatar
  • 31k
6 votes
3 answers
932 views

Ordered squares of an ordered integer array

I had this question in an interview recently. Given a sorted array of integers, return a list of those integers squared, with the squares sorted. So given an array of these numbers: ...
Frank's user avatar
  • 319
7 votes
5 answers
736 views

String combinations of 0 and 1

I was asked this question in an interview: Given a string s consisting of 0, 1 and ...
user5447339's user avatar
1 vote
2 answers
976 views

Leeetcode - Best time to buy and sell stock to get maximum profit

Question Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one ...
Mosbius8's user avatar
  • 787
2 votes
1 answer
1k views

Implement Queue using fixed size array

I came across below interview question and I am working on it: Build a queue class with the enqueue and dequeue methods. The queue can store an UNLIMITED number of elements but you are limited to ...
user5447339's user avatar
4 votes
2 answers
2k views

Trip planning algorithm

I was presented with an interview question described as follows: Receiving an int[] A of cities, where each A[i] has an appeal ...
Power_of_zero's user avatar
3 votes
1 answer
2k views

Counting subtrees where all nodes have the same value

A unival tree (which stands for "universal value") is a tree where all nodes under it have the same value. Given the root to a binary tree, count the number of unival subtrees. For example,...
Maclean Pinto's user avatar
3 votes
1 answer
3k views

Family Relationship Tree

Developer Assignment - Family And Relations Going through the old stuff in his attic, Indiana comes across a chart which looks like a family tree of multiple generations which shows his ...
Maclean Pinto's user avatar
1 vote
1 answer
142 views

Solving a multi variable polynomial

For this equation, I need to count possible solutions: $$ a + b^2 + c^3 + d^4 \le S $$ $$0\le a,b,c,d \le S$$ I tried the following approach: ...
user3857802's user avatar
2 votes
1 answer
55 views

Find the highest result between two elements in an array using their values and indices

I got a programming question on an interview where performance was the focus. I couldnt come up with a better solution than the one below which I think has a time complexity of O(n^2 + n) and scored ...
Niclas Hammar's user avatar
2 votes
2 answers
423 views

Find kth smallest element in binary search tree

I was faced with below interview question today and I came up with below solution but somehow interviewer was not happy. I am not sure why.. Given a binary search tree, find the kth smallest element ...
user5447339's user avatar
3 votes
1 answer
252 views

Map Character to Characters Most Frequently Found With it (in list of strings)

For an interview, I was tasked with writing a program that consumes a list of strings, and produces a mapping between every character in the list, and the characters found most frequently with it (let'...
dfrey's user avatar
  • 31
1 vote
2 answers
946 views

String Compression

Implement a method to perform basic string compression using the counts of repeated characters. For example, the string "aabcccccaaa" would become "a2b1c5a3". If the "...
Exploring's user avatar
  • 345
0 votes
0 answers
7k views

Find the shortest path between two points in a 2D matrix with obstacles

I need to find shortest path between two points in a grid given an obstacles.. Given a 2 dimensional matrix where some of the elements are filled with 1 and rest of the elements are filled. Here X ...
user5447339's user avatar
0 votes
2 answers
91 views

Given an integer number, invert its bits. You cannot use the ~ operator

Here is my code: ...
Maksim Dmitriev's user avatar

15 30 50 per page
1
2 3 4 5 6