Skip to main content

All Questions

3votes
2answers
119views

text format solution

A firm gave me a small take home assignment which asks you to implement text formatter. Given some text which only contains alphanumerics and spaces (only one space between words), we should align it ...
Rohith Uppala's user avatar
4votes
7answers
279views

Breaking a string expression in operator and operands

Requesting for a code review for a scala implementation. Problem Given an expression string made of numbers and operators +,-,/,* , break it in a list of Integer or ...
vikrant's user avatar
3votes
2answers
6kviews

Detecting Intersections of a Collection of Singly-Linked Lists

I was recently presented with the following problem... You are given a collection of singly-linked lists (SLLs). Return true if any of them share a common node (or “intersect”), or false otherwise. ...
James Law's user avatar
6votes
4answers
971views

Counting the number of patterns that exist in a particular string

I am solving this problem where the function returns the number of times a pattern is found in a said string word. It could be easily solved via ...
xyf's user avatar
  • 508
2votes
1answer
158views

Golang solution to CTCI 1.2: Check whether two strings are permutations of each other

Just started learning Go recently. Did some questions from Cracking the Coding Interview book. Wrote the solutions in Go. Let me know what you think. https://github.com/samjingwen/ctci Below is ...
Sam Jing Wen's user avatar
1vote
1answer
90views

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
2votes
3answers
1kviews

Find the 'n' most frequent words in a text, aka word frequency

I'm doing freeCodeCamp's Coding Interview Prep to improve my JavaScript skills. This challenge is called "Word Frequency", and is based on the Rosetta Code's entry of the same name. The ...
NPN328's user avatar
-1votes
1answer
343views

Hackerrank Gridland Metro - using Interval Cover Solution [closed]

Hi there I was hoping to get a better grasp of greddy algorithms while trying to solve this problem: Hackerrank: Gridland Metro and I was trying to apply an algorithm where each grid could be ...
Elliott de Launay's user avatar
2votes
2answers
112views

Print Binary coded decimal Numbering of a given input number

Example 1 input:3 output:0011 Example 2 input : 15 output: 1111 in the below example code 15 is input. I have taken 8 4 2 1 as array for Binary coded decimal numbering this code is working as ...
Ramakrishna's user avatar
3votes
3answers
1kviews

Printing rotations of an array 7 times

Loop through a given array 7 times and print the following output: int[] arr = { 9, 2, 7, 4, 6, 1, 3 }; ...
Ramakrishna's user avatar
2votes
0answers
47views

Find all of the paths that lead to the minimum sum [closed]

"Find minimum path sum" in a 2D grid, is a very popular question which is solved by dynamic programming. But what if instead of the minimum sum value, we return all the actual paths that ...
Athn's user avatar
3votes
1answer
176views

Find minimal modulo-sum of pairs from two lists

Recently I appeared for an job challenge organised on HackerEarth. Question: There are two teams T1 and T2. Power of each player is represented in array. The rules of game are as follow. There are ...
Tanmey Rawal's user avatar
2votes
3answers
84views

Encode message by alphabets - Follow Up

This code is a revised version of implementation which asked for a advice. Original question is here: Encode message by alphabets ...
Erdenebat Ulziisaikhan's user avatar
2votes
1answer
4kviews

The intersection of two polygons in C++

I implemented the intersection of two (convex) polygons in C++. It finds the polygon in the intersection like in this image. Looking for any and all feedback. I left the logic for line intersection ...
James Cagalawan's user avatar
5votes
2answers
769views

Sorting squares of an 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

153050per page
close