05 2016 档案
摘要:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Notice You must
阅读全文
摘要:在Qt中,我们想要通过对话框来打开某一个图片,可以通过使用QFileDialog来快速实现,参见以下代码: 保存图片可以使用如下代码: 类似内容请参见我之前的博客QDialog, QFileDialog 和 QDesktopServices 的使用方法。
阅读全文
摘要:Given an Android 3x3 key lock screen and two integers m and n, where 1 ≤ m ≤ n ≤ 9, count the total number of unlock patterns of the Android lock scre
阅读全文
摘要:在Qt中,有时候我们想要联合QSpinBox 和 QSlider,使得移动滑块,QSpinBox中的数据会变化,或者我们在QSpinBox中输入一个数值,响应的滑块也会变化,如下图所示: 那么我们可以用如下的代码来实现:
阅读全文
摘要:在Qt的界面设计中,我们有时候希望窗口在最大化的时候,上面的控件也跟着缩放,那么我们就需要调整控件的SizePolicy属性,关于这个属性的讲解请参见我之前的博客Qt SizePolicy 属性,由于窗口的拉伸,会导致控件的拉伸,有时候我们只需要某一个或者某几个控件被拉伸,那么我们可以将需要拉伸的控
阅读全文
摘要:Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2] Output: [2,2] Example 2: Input: n
阅读全文
摘要:Factory is a design pattern in common usage. Implement a ShapeFactory that can generate correct shape. You can assume that we have only tree different
阅读全文
摘要:Implement a simple twitter. Support the following method: postTweet(user_id, tweet_text). Post a tweet.getTimeline(user_id). Get the given user's most
阅读全文
摘要:Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2] Output: [2] Example 2: Input: num
阅读全文
摘要:Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3].... Notice You may assume all input has valid answer. Example
阅读全文
摘要:Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3].... Notice Please complete the problem in-place.
阅读全文
摘要:Given a 2D boolean matrix filled with False and True, find the largest rectangle containing all True and return its area. ExampleGiven a matrix: [ [1,
阅读全文
摘要:Given a linked list and two values v1 and v2. Swap the two nodes in the linked list with values v1 and v2. It's guaranteed there is no duplicate value
阅读全文
摘要:18.13 Given a list of millions of words, design an algorithm to create the largest possible rectangle of letters such that every row forms a word (rea
阅读全文
摘要:18.12 Given an NxN matrix of positive and negative integers, write code to find the submatrix with the largest possible sum. 这道求和最大的子矩阵,跟LeetCode上的Max
阅读全文
摘要:18.11 Imagine you have a square matrix, where each cell (pixel) is either black or white. Design an algorithm to find the maximum subsquare such that
阅读全文
摘要:18.10 Given two words of equal length that are in a dictionary, write a method to transform one word into another word by changing only one letter at
阅读全文
摘要:18.9 Numbers are randomly generated and passed to a method. Write a program to find and maintain the median value as new values are generated. LeetCod
阅读全文
摘要:18.8 Given a string s and an array of smaller strings T, design a method to search s for each small string in T. 这道题给我们一个字符串s,和一个字符串数组T,让我们找T中的每一个小字符串
阅读全文
摘要:5.7 Given a list of words, write a program to find the longest word made of other words in the list. 这道题给了我们一个字符串数组,让我们找到最长的那个单词是由字符串数组中的其他单词组成的,LeetC
阅读全文
摘要:18.6 Describe an algorithm to find the smallest one million numbers in one billion numbers. Assume that the computer memory can hold all one billion n
阅读全文
摘要:Design a Tic-tac-toe game that is played between two players on a n x n grid. You may assume the following rules: A move is guaranteed to be valid and
阅读全文
摘要:18.5 You have a large text file containing words. Given any two words, find the shortest distance (in terms of number of words) between them in the fi
阅读全文
摘要:18.4 Write a method to count the number of 2s between 0 and n. 这道题给了我们一个整数n,让我们求[0,n]区间内所有2出现的个数,比如如果n=20,那么满足题意的是2, 12, 20,那么返回3即可。LeetCode上有一道很类似的题F
阅读全文
摘要:18.3 Write a method to randomly generate a set of m integers from an array of size n. Each element must have equal probability of being chosen. 这道题让我们
阅读全文
摘要:在VTK中,我们有时候想要保存vtkImageData类的变量到一幅图片,可以使用如下的实例代码:
阅读全文
摘要:Given a non-empty array of integers, return the k most frequent elements. Example 1: Example 2: Input: nums = [1], k = 1 Output: [1] Example 2: Note:
阅读全文
摘要:18.2 Write a method to shuffle a deck of cards. It must be a perfect shuffle—in other words, each of the 52! permutations of the deck has to be equall
阅读全文
摘要:18.1 Write a function that adds two numbers. You should not use + or any arithmetic operators. 这道题让我们实现两数相加,但是不能用加号或者其他什么数学运算符号,那么我们只能回归计算机运算的本质,位操作Bi
阅读全文
摘要:Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. Example: MovingAverage m = new Movin
阅读全文