摘要:Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two n
阅读全文
摘要:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a...
阅读全文
摘要:QUESTIONA peak element is an element that is greater than its neighbors.Given an input array wherenum[i] ≠ num[i+1], find a peak element and return it...
阅读全文
摘要:QUESTIONThe demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid ...
阅读全文
摘要:QUESTIONImplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will retur...
阅读全文
摘要:QUESTIONGiven an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.FIRST TRYclass Sol...
阅读全文
摘要:QUESTIONRelated to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For examp...
阅读全文
摘要:QUESTIONGiven an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume t...
阅读全文
摘要:QUESTIONGiven a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... ...
阅读全文
摘要:QUESTIONGiven two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is re...
阅读全文
摘要:QUESTIONCompare two version numbers version1 and version1.If version1 > version2 return 1, if version1 integer2) return 1; else if(integer1 i...
阅读全文
摘要:QuestionEvaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or an...
阅读全文
摘要:QUESTIONGiven n points on a 2D plane, find the maximum number of points that lie on the same straight line.1ST TRY/** * Definition for a point. * stru...
阅读全文
摘要:QUESTIONGiven an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.R...
阅读全文