Thursday, 6 May 2021

Find max num in an array

 def maximumSubarray(nums):

  localMax = globalMax = nums[0]
  for ind, num in enumerate(nums[1:]):
    localMax = max(num, num + localMax)
    globalMax = max(localMax, globalMax)

  return globalMax


nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
print('Maximum sum subarray ->' ,maximumSubarray(nums))
# OUTPUT: Maximum sum subarray -> 6

Wednesday, 28 April 2021

amazon

 https://www.geeksforgeeks.org/amazon-interview-experience-for-software-development-engineer-ii/

Thursday, 15 April 2021

interview prog


import java.util.ArrayList;

import java.util.Arrays;

import java.util.List;


public class Tste extends BB {


public static void main(String[] args) {

System.out.println(solution("Sat", 15));

}


public static String solution(String s, int K) {


List<String> list = new ArrayList<String>();

String[] arr = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };

list = Arrays.asList(arr);

int cuurtInd = list.indexOf(s);

String result = "";

if (K <= 0) {

return arr[0];

} else {

int div = K / arr.length;

int reminder = K % arr.length;

System.out.println(cuurtInd);

System.out.println(div);

System.out.println(reminder);

if (cuurtInd + reminder >= arr.length) {

int temp = (cuurtInd + reminder) % arr.length;

result = list.get(temp);

} else

result = list.get(cuurtInd + reminder);


}

return result;

}


}