Akamai Interview Question for Software Developers


Country: United States




Comment hidden because of low score. Click to expand.
1
of 1 vote

// ZoomBA
def ways_to_dist( path, cur_sum , target_value ){
   if ( cur_sum > target_value ) return 0
   if ( cur_sum == target_value  ) {
      println( path )
      return 1
   }
   cnt = 0
   for ( inc : [1,5,10,25 ] ){
     if ( inc >= path[-1] ){
       cnt += ways_to_dist ( path + inc, cur_sum + inc, target_value)
     }
   }
   return cnt
}
println ( ways_to_dist( list(0), 0, 42  ) )

We tried a bit sanity here. BUT, we are not sure, we are going to optimize it further.

- NoOne October 10, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

// ZoomBA
def ways_to_dist( target_value ){
   count = 0
   q = list() // create a queue
   q.enqueue ( [0,0,list(0)] ) // add to it
   // now the loop
   while ( !empty(q) ){
     #( prev_inc , cur_sum , path ) = q.dequeue()
     continue ( cur_sum > target_value ) // obvious, nothing else can do
     continue ( cur_sum == target_value  ) {
       println( path ) // for debug diagnostic
       count +=1 // increment possible scenarios
     }
     for ( inc : [1,5,10,25 ] ){
        if ( inc >= prev_inc ){ // ensure sorted path
           q.enqueue( [ inc , cur_sum + inc , path + inc  ] )
        }
     }
   }
   return count
}
println ( ways_to_dist( 42 ))

This is now a non recursive solution.

- NoOne October 10, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <iostream>
using namespace std;
int coin_chng(int*arr,int n,int sum,int dp[][100])
{
	if(sum==0)
		return 1;
	if(n<0)
		return 0;
	if(dp[sum][n]!=-1)
		return dp[sum][n];
	if(arr[n]>sum)
		return dp[sum][n]=coin_chng(arr,n-1,sum,dp);
	return dp[sum][n]=coin_chng(arr,n,sum-arr[n],dp)+coin_chng(arr,n-1,sum,dp);
}
int main() {
	// your code goes here
	int arr[]={1,5,10,25};
	int sum=5;
	int n=sizeof(arr)/sizeof(arr[0]);
	int dp[100][100];
	for(int i=0;i<=sum;i++)
	{
		for(int j=0;j<n;j++)
			dp[i][j]={-1};
	}
	int num=coin_chng(arr,n-1,sum,dp);
	cout<<"Possible combinations are: "<<num;
	return 0;
}

A D.P approach!(Top down approach)
Tiime complexity-O(n^2)

- Gaurav Agrawal October 21, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class CoinDenomination {

	public static void main(String[] args) {
		double coins[] = {25.0,10.0,5.0,1.0};
		double sum = 2342.5;
		int count = 0;
		
		for(int i=0;i<coins.length;i++){
			count = (int) (sum/coins[i]);
			sum = sum - count * coins[i];
			System.out.println("Denomination for " + coins[i] + " is:" + count);
			count = 0;
		}
		
		if(sum > 0){
			System.out.println("The balance of " + sum + " have no coin denomination available");
		}
		

	}

}

- Anonymous March 16, 2017 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More