본문 바로가기

Interview6

[Linked Lists] removeKFromList Problem: Note: Try to solve this task in O(n) time using O(1) additional space, where n is the number of elements in the list, since this is what you'll be asked to do during an interview. Given a singly linked list of integers l and an integer k, remove all elements from list l that have a value equal to k. Example For l = [3, 1, 2, 3, 4, 5] and k = 3, the output should be removeKFromList(l, k).. 2020. 5. 30.
[Arrays] isCryptSolution - Palantir technologies Problem: A cryptarithm is a mathematical puzzle for which the goal is to find the correspondence between letters and digits, such that the given arithmetic equation consisting of letters holds true when the letters are converted to digits. You have an array of strings crypt, the cryptarithm, and an an array containing the mapping of letters and digits, solution. The array crypt will contain thre.. 2020. 5. 29.
[Arrays] sudoku2 - Apple, Uber Problem: Sudoku is a number-placement puzzle. The objective is to fill a 9 × 9 grid with numbers in such a way that each column, each row, and each of the nine 3 × 3 sub-grids that compose the grid all contain all of the numbers from 1 to 9 one time. Implement an algorithm that will check whether the given grid of numbers represents a valid Sudoku puzzle according to the layout rules described a.. 2020. 5. 29.
[Arrays] rotateImage - Amazon, Microsoft, Apple Problem: Note: Try to solve this task in-place (with O(1) additional memory), since this is what you'll be asked to do during an interview. You are given an n x n 2D matrix that represents an image. Rotate the image by 90 degrees (clockwise). Example For the output should be -Summary- 1. Reverse the matrix first 2. Transpose the matrix to move around the elements. The element will be rotated wit.. 2020. 5. 29.
[Arrays] firstNotRepeatingCharacter - Amazon Problem: Given a string s consisting of small English letters, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'. Example For s = "abacabad", the output should be firstNotRepeatingCharacter(s) = 'c'. There are 2 non-repeating characters in the string: 'c' and 'd'. Return c since it appears in the string first. For s = "abacabaabacaba.. 2020. 5. 29.
[Arrays] firstDuplicate - Google Problem: Given an array a that contains only numbers in the range from 1 to a.length, find the first duplicate number for which the second occurrence has the minimal index. In other words, if there are more than 1 duplicated numbers, return the number for which the second occurrence has a smaller index than the second occurrence of the other number does. If there are no such elements, return -1... 2020. 5. 29.