Fork me on GitHub
上一页 1 2 3 4 5 6 7 8 ··· 16 下一页
摘要: /** * Given a number represented as an array of digits, plus one to the number. * * 给定一个以数字数组表示的数字,再加上一个数字。 */ /** * Given a number represented as an array of digits, plus one to the number. * * 给... 阅读全文
posted @ 2019-08-13 11:20 gentleKay 阅读(198) 评论(0) 推荐(0) 编辑
摘要: /** * Follow up for "Remove Duplicates": * What if duplicates are allowed at most twice? * For example, * Given sorted array A =[1,1,1,2,2,3], * Your function should return length =5, and A is now[1,1... 阅读全文
posted @ 2019-08-13 11:08 gentleKay 阅读(111) 评论(0) 推荐(0) 编辑
摘要: /** * Follow up for "Search in Rotated Sorted Array": * What if duplicates are allowed? * Would this affect the run-time complexity? How and why? * Write a function to determine if a given target is i... 阅读全文
posted @ 2019-08-13 11:07 gentleKay 阅读(191) 评论(0) 推荐(0) 编辑
摘要: /** * Given an integer n, generate a square matrix filled with elements from 1 to n 2 in spiral order. * For example, * Given n =3, * You should return the following matrix: * [ * [ 1, 2, 3 ], * [ 8, 阅读全文
posted @ 2019-08-12 10:49 gentleKay 阅读(136) 评论(0) 推荐(0) 编辑
摘要: /** * Follow up for problem "Populating Next Right Pointers in Each Node". * What if the given tree could be any binary tree? Would your previous solution still work? * Note: * You may only use consta 阅读全文
posted @ 2019-08-12 10:48 gentleKay 阅读(116) 评论(0) 推荐(0) 编辑
摘要: /** * Suppose a sorted array is rotated at some pivot unknown to you beforehand. * (i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2). * You are given a target value to search. If found in the array return 阅读全文
posted @ 2019-08-12 10:47 gentleKay 阅读(138) 评论(0) 推荐(0) 编辑
摘要: /** * Given two sorted integer arrays A and B, merge B into A as one sorted array. * Note: * You may assume that A has enough space to hold additional elements from B. * The number of elements initial 阅读全文
posted @ 2019-08-09 10:34 gentleKay 阅读(128) 评论(0) 推荐(0) 编辑
摘要: /** * Given a binary tree, check whether it is a mirror of itself * (ie, symmetric around its center). * 1 * / \ * 2 2 * / \ / \ * 3 4 4 3 * * 对于二叉树,检查它是否是自身的镜像(即,围绕其中心对称)。 * 例如,此二叉树是对称的: * 1 * / \ * 阅读全文
posted @ 2019-08-09 10:33 gentleKay 阅读(280) 评论(0) 推荐(0) 编辑
摘要: /** * Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. * For example: * Given the below binary tree 阅读全文
posted @ 2019-08-09 10:32 gentleKay 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 解析: * 这道题目的意思是 这个数独是否有效,返回 true, false. * 有三种情况不成立,将返回false: * 第一种: 循环每一行, 如果出现了相同的数字就不成立, 遇到 . 直接跳过 * 第二种: 循环每一列, 如果出现了相同的数字就不成立, 遇到 . 直接跳过 * 第三种: 循环 阅读全文
posted @ 2019-08-08 11:49 gentleKay 阅读(769) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 16 下一页