Pergunta de entrevista da empresa Apple

some basic string searching or reversing linked list. finding maximum sum in a row in the interger array (contains minus) - incorrect solution approach I made here

Respostas da entrevista

Sigiloso

31 de dez. de 2016

I think this question is the max sum subarray question. Can be solved in o(n) using Kadane's algorithm.

1

Sigiloso

27 de fev. de 2017

int maxSubArray(int[] nums) { int n = nums.length; int[] dp = new int[n];//dp[i] means the maximum subarray ending with A[i]; dp[0] = nums[0]; int max = dp[0]; for(int i = 1; i 0 ? dp[i - 1] : 0); max = Math.max(max, dp[i]); } return max; }

Sigiloso

20 de jul. de 2017

int calculate(vector myInts) { int max1 = 0; int max2 = 0; for (auto &i : myInts) { if (max1 < i) { max1 = i; } } for (auto &i : myInts) { if ((max2 < i) && (max1 != i)) { max2 = i; } } return max1 + max2; }

Sigiloso

6 de nov. de 2016

those were not challenging, enjoyed. I prefer reverse engineering skill test on a very large scale code base

Sigiloso

14 de dez. de 2016

To find max sum, find two max numbers in the list and their sum is max sum, O(n) operation