- 博客(56)
- 资源 (2)
- 收藏
- 关注
原创 iOS开发2018校招总结
个人介绍笔者是2018年应届毕业生,软件工程专业,北京某211高校本科生+研究生。学校里主要学了一些软件工程的基本知识,语言、数据结构、数据库、之类的。但是后面也都不记得了。研究生开始学习iOS,后面做了一份iOS开发实习。到校招开始也就几个月的iOS开发经历。校招开始在2018秋招刚开始的时候,笔者的知识储备其实很差,基础知识除了数据结构都不太记得了,iOS相关知识只是了解实习时
2017-12-22 11:36:16
2290
原创 【C++】【LeetCode】152. Maximum Product Subarray
题目Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the largest pro
2017-08-24 10:34:51
397
原创 【C++】【LeetCode】148. Sort List
题目Sort a linked list in O(n log n) time using constant space complexity.思路可以使用归并排序,将链表分为前后两个链表,然后分别排序,进行归并。代码/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNo
2017-08-23 10:49:27
335
原创 【C++】【LeetCode】114. Flatten Binary Tree to Linked List
题目Given a binary tree, flatten it to a linked list in-place.思路有两种方法,第一种比较笨,把所有的点按照前序遍历存入队列,然后取出来构建一棵树;还有一种,把左子树的最右叶子节点找到,将右子树作为最右叶子节点的右子树,然后将左子树作为右子树。代码思路一/** * Definition for a binary tree node. *
2017-08-22 11:49:21
343
原创 【C++】【LeetCode】105. Construct Binary Tree from Preorder and Inorder Traversal
题目Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree.思路前序排列,根结点在最前面;中序排列,根结点前面是左子树的结点,后面是右子数的结点。以此将左右子树分开,又可以按照前序
2017-08-21 12:20:24
307
原创 【C++】【LeetCode】141. Linked List Cycle
题目Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?思路这道题不让用额外的空间,所以很简单,每遍历一个节点,就把它的next指向它本身,也就表明这个节点已经被遍历过了。如果遍历到某个节点,它的next是一个指向自身的节点,即它的n
2017-08-18 19:36:19
303
原创 【C++】【LeetCode】139. Word Break
题目Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You may ass
2017-08-14 10:21:13
523
原创 【C++】【LeetCode】136. Single Number
题目Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra
2017-08-12 12:20:14
315
原创 【C++】【LeetCode】121. Best Time to Buy and Sell Stock
题目Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), de
2017-08-12 11:57:18
319
原创 【C++】【LeetCode】108. Convert Sorted Array to Binary Search Tree
题目Given an array where elements are sorted in ascending order, convert it to a height balanced BST.思路目的是要得到一个平衡二叉树,也就说是每棵数的根节点应该是整棵树上结点的中位数。所以取数组的中位数作为根节点,中位数左边为左子树的数组,右边为右子数的数组。以此类推。代码/** * Definitio
2017-08-12 11:36:53
795
原创 【C++】【LeetCode】102. Binary Tree Level Order Traversal
题目Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level). For example: Given binary tree [3,9,20,null,null,15,7], return its level order
2017-08-11 21:47:00
263
原创 【C++】【LeetCode】101. Symmetric Tree
题目Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric, But the following [1,2,2,null,3,null,3] is
2017-08-11 21:20:09
223
原创 【C++】【LeetCode】75. Sort Colors
题目Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0,
2017-08-11 18:32:29
240
原创 【C++】【LeetCode】98. Validate Binary Search Tree
题目Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node’s key. The
2017-08-08 17:05:31
445
原创 【C++】【LeetCode】96. Unique Binary Search Trees
题目Given n, how many structurally unique BST’s (binary search trees) that store values 1…n? For example, Given n = 3, there are a total of 5 unique BST’s.思路给定n,求不重复二叉查找树的数量,可以分为n种情况,根节点是x(x的取值从1到n),左边
2017-08-06 21:12:54
334
原创 【C++】【LeetCode】92. Reverse Linked List II
题目Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL.Note: Given m, n satisfy the fo
2017-08-05 15:43:41
279
原创 【C++】【LeetCode】79. Word Search
题目Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically
2017-07-30 23:23:41
640
原创 【C++】【LeetCode】77. Combinations
题目Given two integers n and k, return all possible combinations of k numbers out of 1 … n.For example, If n = 4 and k = 2, a solution is: [ [2,4], [3,4], [2,3], [1,2], [1,3],
2017-07-30 16:39:50
491
原创 【C++】【LeetCode】70. Climbing Stairs
题目You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n will be a positiv
2017-07-17 22:53:04
241
原创 【C++】【LeetCode】53. Maximum Subarray
题目Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2,1] has t
2017-07-15 23:58:06
419
原创 【C++】【LeetCode】62. Unique Paths
题目A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the b
2017-07-12 22:18:31
240
原创 【C++】【LeetCode】56. Merge Intervals
题目Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18].思路先给数组排序,这样保证了每个interval的start都是依次递增的,这样只要考虑end的问题。
2017-07-09 16:51:44
591
原创 【C++】【LeetCode】55. Jump Game
题目Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you a
2017-07-09 10:27:53
205
原创 【C++】【LeetCode】54. Spiral Matrix && 59. Spiral Matrix II
题目Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9
2017-06-30 16:21:56
288
原创 【C++】【LeetCode】50. Pow(x, n)
Powx n题目思路代码Pow(x, n)题目Implement pow(x, n).思路pow(x, n),即x的n次方。通过递归,每次判断n是不是2的倍数,如果不是,减1后再除以2,如果n等于1或者-1,返回x或者1/x。代码class Solution {public: double myPow(double x, int n) { map<int, doubl
2017-06-30 15:35:11
315
原创 【C++】【LeetCode】49. Group Anagrams
题目Given an array of strings, group anagrams together. For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”], Return: [ [“ate”, “eat”,”tea”], [“nat”,”tan”], [“bat”] ]思路s
2017-06-25 16:25:13
654
原创 【C++】【LeetCode】48. Rotate Image
题目You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place?思路顺时针旋转一个二维矩阵。通过在纸上演算推出,其实就是把原来坐标为(i, j)的点中的值移到(j, size -
2017-06-25 15:40:52
651
原创 【LeetCode】参照LeetCode上的Solution总结:同类解法
LeetCode上看到的一类提醒的一种解法总结: A general approach to backtracking questions in Java (Subsets, Permutations, Combination Sum, Palindrome Partioning) 原作者是用Java实现的,这里我因为试验,把第一个改成了C++版。 虽然这种解法不见得效率很高,但是不失为在没有
2017-06-25 11:31:02
836
原创 【C++】【LeetCode】43. Multiply Strings
题目Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2.Note: The length of both num1 and num2 is < 110. Both num1 and num2 contains only digits 0-
2017-06-18 20:18:38
528
原创 【C++】【LeetCode】39. Combination Sum&40. Combination Sum II
题目Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from
2017-06-14 10:26:13
475
原创 【C++】【LeetCode】36. Valid Sudoku
题目Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’. Note: A valid Sudoku boar
2017-06-12 23:07:15
317
原创 【C++】【LeetCode】34. Search for a Range
题目Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm’s runtime complexity must be in the order of O(log n). If the tar
2017-06-12 12:55:34
232
原创 【C++】【LeetCode】28. Implement strStr()
题目Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.思路可以利用C++的关于string的函数。 截取字符串:string.substr(i, len); 比较字符串是否以后者开头:strcmp
2017-06-12 10:01:30
234
原创 【C++】【LeetCode】38. Count and Say
题目The count-and-say sequence is the sequence of integers with the first five terms as following: 1 11 21 1211 111221 1 is read off as “one 1” or 11. 11 is read off as “two 1s” or 21.
2017-06-11 16:46:46
280
原创 【C++】【LeetCode】33. Search in Rotated Sorted Array
题目Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target value to search. If found in
2017-06-11 15:51:32
221
原创 【C++】【LeetCode】35. Search Insert Position
题目Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array.
2017-06-11 11:52:24
405
原创 【C++】【LeetCode】31. Next Permutation && 46. Permutations
题目Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible
2017-06-11 11:37:24
441
原创 【C++】【LeetCode】29. Divide Two Integers
题目Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT.思路这题是参考了leetcode上的solution。 这题比较重要的是long long的运用。因为不能使用乘法,除法和取余,所以使用位移。首先排除极端情况,除数为0或者
2017-06-10 11:10:45
315
原创 【C++】【LeetCode】27. Remove Element
题目Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory. The
2017-06-09 17:24:54
297
原创 【C++】【LeetCode】24. Swap Nodes in Pairs
题目Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. You
2017-06-09 17:01:01
212
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人