Interview Questions

Review this list of 4,065 interview questions and answers verified by hiring managers and candidates.
  • Mastercard logoAsked at Mastercard 

    "function findMinMax(array){ array.sort((a,b) => a - b); let min = array[0]; let max = array.slice(-1); return [min,max]; } `"

    Adam S. - "function findMinMax(array){ array.sort((a,b) => a - b); let min = array[0]; let max = array.slice(-1); return [min,max]; } `"See full answer

    Software Engineer
    Technical
  • Apple logoAsked at Apple 

    Coin Change

    IDE
    Medium
    +6

    "The example given is wrong. The 2nd test case should have answer 3, as we can get to 6 by using 3 coins of denomination 2."

    Anmol R. - "The example given is wrong. The 2nd test case should have answer 3, as we can get to 6 by using 3 coins of denomination 2."See full answer

    Backend Engineer
    Coding
    +3 more
  • +1

    "// array is sorted in non-increasing order // low = 0, high = arr.length - 1 int countOnes(int[] arr, int low, int high) { if (high >= low) { int mid = low + (high - low) / 2; if ((mid == high || arr[mid + 1] == 0) && (arr[mid] == 1)) { return mid + 1; } if (arr[mid] == 1) { return countOnes(arr, (mid + 1), high); } return countOnes(arr, low, (mid - 1)); } return 0; }"

    Shubhendu K. - "// array is sorted in non-increasing order // low = 0, high = arr.length - 1 int countOnes(int[] arr, int low, int high) { if (high >= low) { int mid = low + (high - low) / 2; if ((mid == high || arr[mid + 1] == 0) && (arr[mid] == 1)) { return mid + 1; } if (arr[mid] == 1) { return countOnes(arr, (mid + 1), high); } return countOnes(arr, low, (mid - 1)); } return 0; }"See full answer

    Technical
  • "package mycoding.tryexponent.com; import java.util.Scanner; public class FirstAndLastOccurenceOfaNumber { public static void main(String[] arg) { System.out.println("Enter 'a' to run the programme:"); System.out.println("Enter 't' to terminate the programme:"); Scanner in=new Scanner(System.in); String inputtedString=in.nextLine(); while(!"t".equalsIgnoreCase(inputtedString)) { System.out.println("enter a number to find its 1st nd last occurence"); int number=in.nextInt(); int[] array=new i"

    Ankur T. - "package mycoding.tryexponent.com; import java.util.Scanner; public class FirstAndLastOccurenceOfaNumber { public static void main(String[] arg) { System.out.println("Enter 'a' to run the programme:"); System.out.println("Enter 't' to terminate the programme:"); Scanner in=new Scanner(System.in); String inputtedString=in.nextLine(); while(!"t".equalsIgnoreCase(inputtedString)) { System.out.println("enter a number to find its 1st nd last occurence"); int number=in.nextInt(); int[] array=new i"See full answer

    Technical
  • 🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.

  • Microsoft logoAsked at Microsoft 
    Video answer for 'Find the number of rotations in a circularly sorted array.'
    +8

    "function countRotations(arr, low, high) { if (high low && arr[mid] arr[mid]) { return countRotations(arr, low, mid - 1); } return countRotations(arr, mid + 1, high); } "

    Ugo C. - "function countRotations(arr, low, high) { if (high low && arr[mid] arr[mid]) { return countRotations(arr, low, mid - 1); } return countRotations(arr, mid + 1, high); } "See full answer

    Software Engineer
    Data Structures & Algorithms
    +1 more
  • Google logoAsked at Google 

    "Binary search is the technique to search an element in a sorted array in O(log(N)) time. It is also used in problems wherever we find monotonically increasing or decreasing patterns."

    Shivam S. - "Binary search is the technique to search an element in a sorted array in O(log(N)) time. It is also used in problems wherever we find monotonically increasing or decreasing patterns."See full answer

    Frontend Engineer
    Technical
  • "Steps: Validate K to be less than the number of elements in an array. Sort the array in ascending order. Get the K'th smallest element by array[k-1]."

    Ashesh S. - "Steps: Validate K to be less than the number of elements in an array. Sort the array in ascending order. Get the K'th smallest element by array[k-1]."See full answer

  • "As the array is sorted, would it best to use binary search to find the one the triplet and just navigate from it."

    Anonymous Narwhal - "As the array is sorted, would it best to use binary search to find the one the triplet and just navigate from it."See full answer

    Technical
  • "bool isConsecutive(int arr[], int n) { // base case if (n max) { max = arr[i]; } } // for an array to contain consecutive integers, the difference between // the maximum and minimum element in it should be exactly \n-1\ if (max - min != n - 1) { return false; } // create an empty set (we can also use a visit"

    Hinata T. - "bool isConsecutive(int arr[], int n) { // base case if (n max) { max = arr[i]; } } // for an array to contain consecutive integers, the difference between // the maximum and minimum element in it should be exactly \n-1\ if (max - min != n - 1) { return false; } // create an empty set (we can also use a visit"See full answer

  • "It will need a method to extract sub_arr from arr with distinct elements. ex. arr: [1,2,3,1] sub_arr: [1],[2],[3],[1,2],[1,2,3],[2,3], [2,3,1]"

    Deepak S. - "It will need a method to extract sub_arr from arr with distinct elements. ex. arr: [1,2,3,1] sub_arr: [1],[2],[3],[1,2],[1,2,3],[2,3], [2,3,1]"See full answer

    Technical
  • Adobe logoAsked at Adobe 

    "#include #include #include using namespace std; void printComs(int prev, int start, int end, int target) { if (start >= end) return; while (start target) { end--; } else { st"

    Iris F. - "#include #include #include using namespace std; void printComs(int prev, int start, int end, int target) { if (start >= end) return; while (start target) { end--; } else { st"See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • "public static Dictionary FindPairsWitkkDifference(int k, int[] nums) { Dictionary pairsWithkDifference = new Dictionary(); int n = nums.Length; if( n== 0 || n == 1) Return 0; for(int i =0; i< n;i++) { for(int j = i+1; j < n; j++) { if(Math.Abs(nums[i] - nums[j]) == k) { pairsWithkDifference(nums[i], nums[j]); } } } Return pairsWithkDifference ; }"

    Sanobar K. - "public static Dictionary FindPairsWitkkDifference(int k, int[] nums) { Dictionary pairsWithkDifference = new Dictionary(); int n = nums.Length; if( n== 0 || n == 1) Return 0; for(int i =0; i< n;i++) { for(int j = i+1; j < n; j++) { if(Math.Abs(nums[i] - nums[j]) == k) { pairsWithkDifference(nums[i], nums[j]); } } } Return pairsWithkDifference ; }"See full answer

    Technical
  • Adobe logoAsked at Adobe 
    Video answer for 'Find a triplet in an array with a given sum.'
    +9

    "from typing import List def three_sum(nums: List[int]) -> List[List[int]]: nums.sort() triplets = set() for i in range(len(nums) - 2): firstNum = nums[i] l = i + 1 r = len(nums) - 1 while l 0: r -= 1 elif potentialSum < 0: l += 1 "

    Anonymous Roadrunner - "from typing import List def three_sum(nums: List[int]) -> List[List[int]]: nums.sort() triplets = set() for i in range(len(nums) - 2): firstNum = nums[i] l = i + 1 r = len(nums) - 1 while l 0: r -= 1 elif potentialSum < 0: l += 1 "See full answer

    Software Engineer
    Data Structures & Algorithms
    +3 more
  • Apple logoAsked at Apple 
    Software Engineer
  • Adobe logoAsked at Adobe 
    +7

    "from typing import List def traprainwater(height: List[int]) -> int: if not height: return 0 l, r = 0, len(height) - 1 leftMax, rightMax = height[l], height[r] res = 0 while l < r: if leftMax < rightMax: l += 1 leftMax = max(leftMax, height[l]) res += leftMax - height[l] else: r -= 1 rightMax = max(rightMax, height[r]) "

    Anonymous Roadrunner - "from typing import List def traprainwater(height: List[int]) -> int: if not height: return 0 l, r = 0, len(height) - 1 leftMax, rightMax = height[l], height[r] res = 0 while l < r: if leftMax < rightMax: l += 1 leftMax = max(leftMax, height[l]) res += leftMax - height[l] else: r -= 1 rightMax = max(rightMax, height[r]) "See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • "function biggestNumber(array) { if (!array) return null; let number = array[0] for(let i; i < array.length; i++) { if (number <= array[i]) number = array[i]; } return number } `"

    Arinze O. - "function biggestNumber(array) { if (!array) return null; let number = array[0] for(let i; i < array.length; i++) { if (number <= array[i]) number = array[i]; } return number } `"See full answer

Showing 3061-3080 of 4065