自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Tech in Pieces

Technical blog of Evan Sun

  • 博客(44)
  • 收藏
  • 关注

原创 024 Concate Swaps

we can have a split the s into string array. and we swap it. and then use a stringbuilder to rebuild them and return.simple but effective.

2020-09-29 12:19:58 218

原创 022 Plus/subtract Number

given an integer.-±±+all the digits, get the final results.we can get the digits one by one, add it to list. (list.add(list.size() - 1, digit));and then we -±+ them, return the results.

2020-09-29 12:03:40 221

原创 021 Black White Sort Matrix

now we are given a matrix full of positive integers.and an array of queries are also given, the format of the query is: [x, y, m], it represent we need to sort a submatrix with dimension of m*m, the left-top corner is [x,y].so we keep doing that until al

2020-09-29 11:58:24 337

原创 020 K occourrence

given a string word, a string sequenceif word only happens in sequence once consecutively, then we call it 1 occourrence .like word = “ab” and sequence = “dabcacab”, then it is a 1-occurrence.now we are given a sequence and a bunch of words(queries), ch

2020-09-29 11:33:47 295

原创 019 Check ABC(longest subarray check)

we are given three array of integers.let say a, b and cc is an array with distinct integers.now we need to check whether b is the longest subarray of a consisting only of elements from c.the means:each element of b must belongs to cb is a subarray of

2020-09-29 10:43:58 399

原创 017 isZigZag

given an array, for each triplet, return if it is zigzag or not, and return them as the an array. 1 is zigzag 0 is not.public class zigzagArray { public zigzagArray() { } public boolean[] solution(int[] array) { int n = array.length;

2020-09-29 09:15:43 353

原创 014 Matrix Queries

given a matrix, n * mthe value of each position of this matrix is board[i][j] = (i+1)(j+1)now we have some queries.[0] find the minimum values among all the remaining active cells on board.[1, i] deactivate all the cells in row i[2, j] deactivate all

2020-09-29 08:32:35 477

原创 012 Border Sort

given a nn matrix full of integers.now we know matrix has many layers, so for nn, we have n/2 layers.now, we need to sort each layer, and relocate them clockwise, starting from the top left position.idea: of course we can get every element for each laye

2020-09-29 05:52:50 530

原创 011 Reverse Digits in Pairs

reverse them in pairpublic class reverseDigitspair { public int solution(int digit){ if(digit<10) return digit; String str = String.valueOf(digit); char[] string = str.toCharArray(); int i=0; while(i<strin

2020-09-29 05:36:27 591

原创 009 Justify Newspaper Text

public class justifyNewspaperText { public static final String STAR = "*"; public static final String SPACE = " "; public static final String[] POS = new String[]{"LEFT", "RIGHT"}; public justifyNewspaperText() { } public static .

2020-09-29 05:16:23 463

原创 006 Given a matrix, rearrange its number

first, sort the values in this matrix by its frequency. if there is a tie, then order them by their values.then, place the sorted number diagonally, starting from the bottom right corner, like the following:5 4 44 4 33 2 1brute force:first we sort th

2020-09-28 05:38:36 325

原创 005 Number of ways to remove one digit from a string so it lexicographically smaller than other se

Given two string, s and t.both consisting of lowercase letters and digits.now we want to make s lexicographically smaller than t.rules: remove only one digit from s.now return how many ways can we do this.Pay attention: digits are smaller than letter

2020-09-28 05:03:23 1145

原创 004 Can Make Triangle

given an array with all the elements are positive.check if elements can form a triangle.return an array called res, with length of arr.length-2, and res[i] = 1 if it is possible to form a triangle with arr[i] arr[i+1], arr[i+2], otherwise 0;couldn’t be

2020-09-28 04:35:00 250

原创 002 给一串string 比如“I have a card”再给一个键盘char[]。 键盘里有h,a,v,e。问句子里几个字可以被键盘打出来。只有have和a可以。 然后所有标点符号都可以被打出来

get the number of words where all of its characters are in the given keyboard array.the naive way to check it is: break every word. and checking every char in each word. if every char is in, then we have a part of our solution.HashSet<Character> se

2020-09-28 04:15:26 336

原创 001 给一串int[] 找出所有arr[i-1]+arr[i+1]=2*arr[i]的情况

idea: from the index1 to indexlength-2, iterate everythingif arr.length <= 2 return nothingint i = 1;while (i <= arr.length - 2) {if (arr[i-1]+arr[i+1] == 2*arr[i]) {//}}returnwe can’t use presort because order matters.this O(n) solution is

2020-09-28 04:00:22 450

原创 how to initialize a stack?

Stack stack = new Stack() is not recommended.andDeque deque = new ArrayDeque<>(); is a better waybut keep in mind that the method of deque is quite different than stack.but why deque is better than stack?Object oriented design - Inheritance, ab

2020-09-14 01:26:35 131

原创 Merge Two Sorted Lists

it’s like the “merge” part in merge sort.pay attention, it is required that:The new list should be made by splicing together the nodes of the first two lists.so that means we can’t have a new linkedlist. and we can only do something on those two given l

2020-09-14 00:13:36 126

原创 Add Two Numbers

add two linkedlist.example:Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)Output: 7 -> 0 -> 8Explanation: 342 + 465 = 807.and the solutions will be like follows:class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) {

2020-09-13 23:28:43 67

原创 Trapping Rain Water

another classic problem.

2020-09-13 23:00:08 63

原创 Reorder Log Files

You have an array of logs. Each log is a space delimited string of words.For each log, the first word in each log is an alphanumeric identifier. Then, either:Each word after the identifier will consist only of lowercase letters, or;Each word after the

2020-09-13 09:56:57 146

原创 Most Common Word

Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at least one word that isn’t banned, and that the answer is unique.Words in the list of banned words are given

2020-09-13 09:19:51 158

原创 Valid Parentheses

classic stack problem.class Solution { public boolean isValid(String s) { if (s == null || s.length() == 0) return false; if (s.length() % 2 == 1) return false; Stack<Character> stack = new Stack<>();

2020-09-13 01:15:22 61

原创 First Unique Character in a String

Given a string, find the first non-repeating character in it and return its index. If it doesn’t exist, return -1.unique->hashset.but hashset can only do binary things, like if I find again, the only way to show I found again is remove this key, but w

2020-09-13 00:45:31 77

原创 Integer to English Words

essentially, this is exactly the same with Integer to Roman or Integer to any other calculate method.I hate questions like this, let’s hope I won’t met problems like this in a real interview.class Solution { String[] less20 = {"", "One", "Two", "Thre

2020-09-13 00:13:06 101

原创 Missing Number

Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.do it in linear time complexity and constant extra space.iterate them once, and we can only use swap (at least it looks like we have to do

2020-09-12 23:54:22 67

原创 Compare Version Numbers

given two version numbers in the format of string, if 1>2, return 1, else if 1<2, return -1, else return 0.so it’s like a new comparator.but an easy problem like this, you can’t even solve it.followings are the shit code you wrote.class Solution

2020-09-12 12:20:33 150

原创 Minimum Window Substring (Unsolved)

given two strings, say it’s S and T.we need to find the minimum windows in S that contains every chars in T, and we don’t need them to be in the exactly same order.please do this in a time complexity of O(N)other things needs to keep in mind:if there i

2020-09-12 11:26:30 181

原创 Group Anagrams

given an array of strings, return a 2d array that each element in that is a grouped array contains anagrams.first, we need to iterate this array at least once.and then, we need to group them based on the exactly same characters they used. but how can we

2020-09-12 01:15:13 84

原创 Rotate Image

Rotate a matrix clockwise, 90 degree.do it in-place.how to do it in place?remember, do it in place doesn’t mean that we don’t need extra space. in fact, we do.so if we takes an element and put it down in its new place, the original element here will be

2020-09-11 11:13:02 76

原创 Implement strStr()

basically, we need to implement indexOf()so this problem is actually a string matching problem.we met many of such algorithm

2020-09-11 10:47:26 120

原创 按钮文本左对齐/右对齐

https://www.jianshu.com/p/9f0227876b6c但是好像只对UIButton有效 对AttributedButton无效

2020-09-09 08:44:54 788

原创 如何提升IOS app流畅度

reference: https://blog.ibireme.com/2015/11/12/smooth_user_interfaces_for_ios/这篇文章十分详尽的讲解了原理和优化方法,有时间可以仔细研究一下。

2020-09-09 01:02:24 242

原创 3 Sum Closest

now we need find the triplet in a given array.we only need to find the closest triplets and return it, that’s all.first, we know there is a limitness of being close, 0, so if we find something which sums to exactly the target, and then we break.but if w

2020-09-08 11:56:16 117

原创 3 Sum

classic sum problems.given an array may contains duplicates, return all the unique triplet which sum equals to 0.a classic way is to presort it, and use three pointers, the first one will be single direction, and the other two will be opposite direction

2020-09-07 23:48:23 78

原创 Integer to Roman

given rules, to some kind of covert stuff.class Solution { public String intToRoman(int num) { int[] decimal = {1000,900,500,400,100,90,50,40,10,9,5,4,1}; String[] roman = {"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};

2020-09-07 11:19:54 67

原创 Container With Most Water

classic water container problems.using left and right pointer. find the one that constraint the height of this container, and move to find a potential larger one.class Solution { public int maxArea(int[] height) { int res = 0; int l =

2020-09-07 11:16:07 84

原创 String to Integer (atoi)

convert string to integer.pay attention to the following problems:the number might be positive/negative.there might be spaces on the first/lastthere might be other characters in the given string, and if the first char is a non numerical char, then we r

2020-09-07 10:57:44 57

原创 LeetCode003 Longest Substring Without Repeating Characters

we just need to return the number of that longest substring.substring problem, maybe sliding window?and we need to sliding over till the end to make sure we get the longest one. but for every substring we count as a potential answer, we need to make sure

2020-09-07 09:59:42 131

原创 衡量一个社交类APP的指标有哪些

https://www.zhihu.com/question/27693510第一个回答的用户给出了九个比较详尽的指标:作者:知乎用户链接:https://www.zhihu.com/question/27693510/answer/37666764来源:知乎著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。九个最重要的KPI指标,它们可以评估移动App应用软件是否成功。  1.用途  用户评价一款App应用时,会首先是从它的用途入手,而真正成功的App应用能够解决用户所面临

2020-09-06 00:48:57 1565

原创 如何提升APP日活(DAU)?

https://www.zhihu.com/question/28385350第一个回答还是给人一些启发的。一、找到用户兴趣点1、你的用户,对哪些内容感兴趣,你就做好,投其所好。这些一方面需要用户调研,一方面需要自己来分析。2、数据分析用户喜好APP内的数据,看看哪些点击量大。从用户体验角度看,点击量大的放前面。二、服务好我们的客服的服务,会影响用户对产品的印象。搜易客服要服务好。三、做一些功能1、利益驱动。签到赚钱。比如万富黑卡APP上的签到送金币。赚钱的功能比如万富黑卡APP上的邀请赚钱,

2020-09-06 00:36:28 2225

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除