Skip to main content

All Questions

2 votes
1 answer
93 views

Is there a route to the end of the jump table?

I'm currently learning about Dynamic Programming and solving a "coding question" related to the topic. Given an array of non-negative integers, you are initially positioned at the first ...
Somya Agrawal's user avatar
3 votes
1 answer
357 views

Find the smallest number of perfect squares that sum to a target

Given a positive integer n, find the smallest number of perfect squares (for example, 1, 4, 9, 16, ...) that sum to n. ...
Somya Agrawal's user avatar
3 votes
0 answers
230 views

Longest Palindrome Substring: Where is the dynamic programming? [closed]

In this LeetCode problem, Longest Palindromic Substring, it is listed under Dynamic Programming for Google interview preparation. My understanding of dynamic programming is roughly "recursion + ...
Scott Skiles's user avatar
3 votes
2 answers
254 views

Longest common subsequence solution

I've seen this today on a mock interview and wanted to give it a try. I'd love to hear some feedback from you guys. This is my second attempt at the problem, initially I had a mess of ...
fpezzini's user avatar
  • 326
3 votes
1 answer
10k views

Solving maze problem with backtracking solution using stack

I solved the maze backtracking question using a stack however could not find any other solution like that anywhere (to validate my solution is actually a valid one). The problem statement is as ...
crazyPixel's user avatar
3 votes
0 answers
2k views

Robot on a Grid: Find a path between two corners with forbidden cells on the road

Problem statement The problem is defined in the book as following: 8.2 Robot in a Grid Imagine a robot sitting on the upper left corner of grid with r rows and <...
Igor Soloydenko's user avatar
0 votes
2 answers
958 views

Number of Paths (BackTracking) in Java

Illustration You're testing a new driverless car that is located at the Southwest (bottom-left) corner of an n×n grid. The car is supposed to get to the opposite, Northeast (top-right), corner ...
Anirudh Thatipelli's user avatar
5 votes
1 answer
670 views

Longest Arithmetic Progression Algorithm

Problem Statement: > Given a sorted array, find the length of the longest arithmetic progression in it. Examples: numbers = new int[]{1, 3, 4, 5, 7, 8, 9} The length is 5, and the sequence ...
Jianmin Chen's user avatar
  • 2,416
1 vote
1 answer
920 views

Solving "Quadruple sum" problem using dynamic programming

I am trying to learn dynamic programming using hash table. I was given this the "Quadruple sum" problem from firecode.io as a challenge: Given a sorted array of integers and an integer target, find ...
NinjaG's user avatar
  • 2,539
2 votes
1 answer
2k views

Regular Expression Matching: Recursive and DP-based implementation

Problem Statement: Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching ...
mycleanlittlescrete's user avatar
6 votes
2 answers
2k views

Length of longest palindrome subsequence

I had an interview, where I was asked to solve to this question: Given an string str, find the maximum length of palindrome subsequence. Example: >if str = 'abcda': maximum_length = 3 'aca' How ...
Harsha's user avatar
  • 1,301
2 votes
1 answer
207 views

0-1 Knapsack in Java

I'm looking for advice on coding practices in general. ...
DontForgetTheSemiColon's user avatar
11 votes
1 answer
2k views

House-coloring optimization challenge

I have an interview coming up in the next few weeks, and I'm choosing to be interviewed in Python. I began programming in Python (it was about four years ago), so the syntax is natural to me, but I ...
Mark Miller's user avatar
5 votes
1 answer
1k views

Word break problem with dynamic programming

This is the original question. I have implemented it in both ways. If I enter the word "icecream", should I output "ice" "cream" and also "icecream", or just "ice" and "cream"? Is this a good ...
Gilad's user avatar
  • 5,293
7 votes
2 answers
4k views

Finding alternating sequence in a list of numbers

Please be brutal and treat this as me coding this up for an interview. A sequence of numbers is called a zig-zag sequence if the differences between successive numbers strictly alternate between ...
bazang's user avatar
  • 2,236