Lintcode41 Maximum Subarray solution 题解
【题目描述】Given an array of integers, find a contiguous subarray which has the largest sum.Notice:The subarray should contain at least one number.给定一个整数数组,找到一个具有最大和的子数组,返回其最大和。注意:子数组最少包含一个数【题目链接】http://...
Lintcode17 Subsets solution 题解
【题目描述】Given a set of distinct integers, return all possible subsets.Notice:Elements in a subset must be in non-descending order;The solution set must not contain duplicate subsets.给定一个含不同整数的集合,返回其所有的子集注意:子集中的元素排列必须是非降序的,...
Lintcode16 Permutations II solution 题解
【题目描述】Given a list of numbers with duplicate number in it. Find all unique permutations.给出一个具有重复数字的列表,找出列表所有不同的排列。【题目链接】http://www.lintcode.com/en/problem/permutations-ii/ 【题目解析】跟 Permutations的解法一样,就是要考虑“去重”。先对数组进行排序,这样在D...
Lintcode15 Permutations solution 题解
【题目描述】Given a list of numbers, return all possible permutations.Notice:You can assume that there is no duplicate numbers in the list.给定一个数字列表,返回其所有可能的排列。注意:你可以假设没有重复数字。【题目链接】http://www.lintcode.com/en/problem/permutations/ 【题目解析】遇到这种问...
Lintcode14 First Position of Target Solution 题解
【题目描述】For a given sorted array (ascending order) and a target number, find the first index of this number in O(log n) time complexity.If the target number does not exist in the array, return -1.给定一个排序的整数数组(升序)和一个要查找的整数target,用O(logn)的时间查找到target第一次出现的下...
Lintcode13 strStr solution 题解
【题目描述】For a given source string and a target string, you should output the first index(from 0) of target string in source string.If target does not exist in source, just return -1.对于一个给定的 source 字符串和一个 target 字符串,你应该在 source 字符串中找出 target 字符串出现的第一个位置(从...
Apple Software Engineer Onsite 面经
得到这次面试机会,是在一个 hackathon 上遇到的 recruiter 给我发的邀请。在 hackathon 上无意中遇到 recruiter,跟他简单聊过我以前的项目经验, recruiter 对我还挺满意的,所以有了这次面试。之前已经面了一轮电面,主要问了一些数据结构的问题,还有相关的项目经验。onsite 面试内容包括算法和 system desig...
Lintcode12 Min Stack solution 题解
【题目描述】Implement a stack with min() function, which will return the smallest number in the stack.It should support push, pop and min operation all in O(1) cost.Notice:min operation will never be called if there is no number in the stack.实现一个带有取最小值min方法的栈,min方法...
Lintcode11 Search Range in Binary Search Tree solution 题解
【题目描述】Given two values k1 and k2 (where k1 < k2) and a root pointer to a Binary Search Tree. Find all the keys of tree in range k1 to k2. i.e. print all x such that k1
Lintcode9 Fizz Buzz solution 题解
【题目描述】Given number n. Print number from 1 to n. But:when number is divided by 3, print "fizz".when number is divided by 5, print "buzz".when number is divided by both 3 and 5, print "fizz buzz".给你一个整数n. 从 1 到 n 按照下面的规则打印每个数:如果这个数被3整除,打印...
Lintcode8 Rotate String solution 题解
【题目描述】Given a string and an offset, rotate string by offset. (rotate from left to right)给定一个字符串和一个偏移量,根据偏移量旋转字符串(从左向右旋转)【题目链接】http://www.lintcode.com/en/problem/rotate-string/【题目解析】常见的翻转法应用题,仔细观察规律可知翻转的分...
Lintcode7 Binary Tree Serialization solution 题解
【题目描述】Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is called ‘serialization’ and reading back from the file to reconstruct the exact same binary tree is ‘deserialization’.设计一个算法,并编写代码来序列化和反序列化二叉树。...
程序员常用的刷题网站
1、LintcodeLintcode.com——LintCode网站是国内较大的在线编程&测评网站。此网站提供各大IT公司的算法面试题类型,行分门别类,由简单到中等,再到难,便于不同水平的程序员进行刷题练习。同时网站支持多种语言(Java, Python, C++),方便不同语言特长的程序员利用擅长语言进行刷题练习。因此对于不同编程能...