All Questions
10 questions
2
votes
2
answers
410
views
Median of two sorted arrays in Python
Problem Statement
(Source: Leetcode Problem 4: Median of Two Sorted Arrays [Hard])(Topics: [Array] [Binary Search] [Divide and Conquer])
Given two sorted arrays ...
2
votes
1
answer
217
views
Hackerrank "New Year chaos" solution - permute sequence by swapping adjacent terms
I was doing the Hackerrank "New Year chaos" problem. Here is the description:
It is New Year's Day and people are in line for the Wonderland
rollercoaster ride. Each person wears a sticker ...
3
votes
1
answer
1k
views
Median of two sorted arrays
The task is to find the median of two Arrays. I have an O(n) solution.
Can it be written in a better time complexity?
...
7
votes
1
answer
1k
views
Intersection of two lists in Python
I am currently working on an algorithm, which involves finding the intersection of two lists. That is, given the following inputs [1,2,2,1],...
11
votes
4
answers
3k
views
Maximum consecutive subarray sum for a variable sliding window size
The Problem:
Given an array of integers L find the largest sum of a consecutive subarray of size k or less.
Constraints:
...
4
votes
4
answers
1k
views
Find element that has been removed from a shuffled array
For a function to determine which element has been removed from a shuffled array, I came up with:
...
2
votes
1
answer
3k
views
Find the longest subarray with sum less than K
The problem consist of finding the longest contiguous subarray with a sum less than a given integer K.
The input data are:
K - ...
2
votes
1
answer
6k
views
HackerRank: Left Array Rotation in Python
Here is the problem on HackerRank. I want to know how I can improve this code. I am mainly trying to improve the following skills: Documentation, functional programming (top-down approach), accurately ...
3
votes
3
answers
9k
views
Intersection of subset between two lists of dicts
I want to find the intersection of two lists of dicts.
Note that equality—i.e.: what is to appear in the intersection—is given by which keys they must have equal. See the ...
3
votes
5
answers
2k
views
count all array[index] == index occurrences
The method foo gets a sorted list with different numbers as a parameter and returns the count of all the occurrences such that: ...