All Questions
18 questions
3
votes
2
answers
340
views
Given an array, remove zero or more elements to maximize the reduction where you add odd values and subtract even values
Here's a code challenge I got. (I could not solve the challenge, I ran out of time. I rephrased the challenge language and I am trying the challenge again for personal growth & computer science ...
6
votes
3
answers
316
views
Largest Triple Products without using sort?
I implemented the Largest Triple Products algorithm, but I use sort which makes my time complexity \$O(n *log(n))\$. Is there a way to implement it without a temporary sorted array?
The problem:
You'...
4
votes
2
answers
302
views
Maxcounters in JavaScript
I am trying to solve this question: MaxCounters.
Solving it is straightforward, but solving it fast enough is proving very difficult. How can I improve the performance of this code? At the moment it ...
2
votes
1
answer
1k
views
Codewars: Pick peaks
Pick peaks
Wrote my "hello world" on Thursday, so definitely a beginner. I know some Python, so not a novice to programming in general.
Question
For example, the array ...
-2
votes
1
answer
189
views
Challenge - Construct binary tree from array [closed]
A coding challenge to construct a binary tree from an array.
...
3
votes
2
answers
2k
views
Counting Valleys - HackerRank Challenge
For this challenge on HackerRank:
A valley is a sequence of consecutive steps below sea level, starting with a step down from sea level and ending with a step up to sea level.
Given Gary's ...
8
votes
5
answers
4k
views
Find The One Element In An Array That is Different From The Others
https://www.codewars.com/kata/find-the-stray-number/train/javascript
I solved this challenge by sorting from least to greatest, and checking if the first element in the array matched the second ...
11
votes
5
answers
1k
views
Easy to read palindrome checker
I made a palindrome checker that's supposed to be designed to be simple and easy to read. Please let me know what you think. I believe the time complexity is \$\mathcal{O}(n)\$ but I'm not too sure ...
0
votes
3
answers
299
views
Finding nth lowest value without any Math max or min methods
So I decided to make a more efficient solution to a Google interview question where they ask you to either find the lowest or second lowest value in an array without using the max or min methods. I ...
1
vote
2
answers
453
views
JavaScript Spiral Matrix Coding Challenge
A whiteboarding challenge: Given a 2D array (matrix) inputMatrix of integers, create a function spiralCopy that copies ...
7
votes
2
answers
3k
views
Deepest pit of an array
Following is based on a problem description from a Codility test, as a task in an interview.
DeepestPit - problem description
A non-empty zero-indexed array B ...
2
votes
1
answer
210
views
HackerRank - Left Rotation in JavaScript
I'm looking to learn more about data structures, time complexity, and efficient algorithms. I have solved the Left Rotation Problem
on HackerRank using JavaScript. I am looking to see ways to optimize ...
10
votes
2
answers
700
views
Array duplicate removal for duplicates exceeding `N`-number
I recently encountered a front-end interview coding challenge question that required one to create a function which returned an array that excluded numbers that occurred more than ...
3
votes
3
answers
7k
views
Function to find the shortest word in an array, where not every element is a string
I wrote a solution for a codeCamp exercise:
Write a function called findShortestWordAmongMixedElements.
Given an array, ...
3
votes
1
answer
5k
views
Codewars "Consecutive strings" kata
The challenge description is as follows:
You are given an array strarr of strings and an integer k. Your task is to return the ...