• Home
  • Blog
  • Publications
  • Resume
  • 简历
Jin Shang(尚晋) logo

Blog

  • C++17在业务代码中最好用的十个特性
    May 15, 2022

    C++17在业务代码中最好用的十个特性

    自从步入现代C++时代开始,C++语言标准形成了三年一个版本的惯例:C++11标志着现代C++的开端,C++14在11的基础上查缺补漏,并未加入许多新特性,而C++17作为C++11后的第一个大版本,标志着现代C++逐渐走向成熟。WXG编译器升级到gcc7.5已有一段时间,笔者所在项目组也已经将全部代码升级到C++17。在使用了c++17一年多之后,笔者总结了C++17在业务代码中最好用的十个特性。

  • JustMySocks+Qv2ray极简教程
    August 03, 2020

    justmysocks 官网链接

  • Tree Traversal
    October 23, 2019

    Tree traversal algorithms: pre_order, in_order, post_order

  • SweepLine
    October 23, 2019

    SweepLine algorithm for finding all intersections

  • Palinedrome Number
    October 23, 2019

    Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.

  • String to Integer (atoi)
    October 23, 2019

    Implement atoi which converts a string to an integer.

  • Daily temperatures
    October 23, 2019

    Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead.

  • Edit distance
    October 23, 2019

    Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2.

  • Reverse Integer
    October 23, 2019

    Given a 32-bit signed integer, reverse digits of an integer.

  • Palindromic Substrings
    October 23, 2019

    Given a string, your task is to count how many palindromic substrings in this string.

  • Task Scheduler
    October 23, 2019

    Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks could be done without original order. Each task could be done in one interval. For each interval, CPU could finish one task or just be idle.

  • Merge Two Binary Trees
    October 23, 2019

    Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.

  • Zigzag Conversion
    October 23, 2019

    The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)

  • Shortest Unsorted Continuous Subarray
    October 23, 2019

    Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too.

  • Subarray Sum Equals K
    October 23, 2019

    Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.

  • Diameter of Binary Tree
    October 23, 2019

    Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.

  • Longest Palindromic Substring
    October 23, 2019

    Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.

  • Target Sum
    October 23, 2019

    You are given a list of non-negative integers, a1, a2, …, an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.

  • Find All Numbers Disappeared in an Array
    October 23, 2019

    Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.

  • Find all Anagrams in a String
    October 23, 2019

    Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s.

  • Path Sum III
    October 23, 2019

    You are given a binary tree in which each node contains an integer value.

  • Partition Equal Subset Sum
    October 23, 2019

    Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.

  • Queue Reconstruction by Height
    October 23, 2019

    Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of this person who have a height greater than or equal to h. Write an algorithm to reconstruct the queue.

  • Median of Two Sorted Array
    October 23, 2019

    There are two sorted arrays nums1 and nums2 of size m and n respectively.

  • Next Permutation
    October 23, 2019

    Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.

  • Longest Substring Without Repeating Characters
    October 23, 2019

    Given a string, find the length of the longest substring without repeating characters.

  • Divide Two Integers
    October 23, 2019

    Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.

  • Implement strStr()
    October 23, 2019

    Implement strStr().

  • Remove Element
    October 23, 2019

    Given an array nums and a value val, remove all instances of that value in-place and return the new length.

  • Remove Duplicates from Sorted Array
    October 23, 2019

    Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.

  • Reverse Nodes in k-Group
    October 23, 2019

    Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.

  • Swap Nodes in Pairs
    October 23, 2019

    Given a linked list, swap every two adjacent nodes and return its head.

  • Merge K Sorted Lists
    October 23, 2019

    Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.

  • Generate Parentheses
    October 23, 2019

    Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

  • Merge Two Sorted Lists
    October 23, 2019

    Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.

  • Valid Parentheses
    October 23, 2019

    Given a string containing just the characters '(', ')', '{', '}', '['and ']', determine if the input string is valid.

  • Add Two Numbers
    October 23, 2019

    You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

  • Remove Nth Node From End of List
    October 23, 2019

    Given a linked list, remove the n-th node from the end of list and return its head.

  • 4 Sum
    October 23, 2019

    Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.

  • Letter Combinations of a Phone Number
    October 23, 2019

    Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.

  • 3Sum Closest
    October 23, 2019

    Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution.

  • 3Sum
    October 23, 2019

    Given an array nums of n integers, are there elements a, b, c in numssuch that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.

  • Longest Common Prefix
    October 23, 2019

    Write a function to find the longest common prefix string amongst an array of strings.

  • Roman to Integer
    October 23, 2019

    Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.

  • Count Vowels Permutation
    October 23, 2019

    Given an integer n, your task is to count how many strings of length n can be formed under the following rules:

  • Path with Maximum Gold
    October 23, 2019

    In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty.

  • Longest Arithmetic Subsequence of Given Difference
    October 23, 2019

    Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the difference between adjacent elements in the subsequence equals difference.

  • Play with Chips
    October 23, 2019

    There are some chips, and the i-th chip is at position chips[i].

  • Minimum Moves to Reach Target with Rotations
    October 23, 2019

    In an n*n grid, there is a snake that spans 2 cells and starts moving from the top left corner at (0, 0) and (0, 1). The grid has empty cells represented by zeros and blocked cells represented by ones. The snake wants to reach the lower right corner at (n-1, n-2) and (n-1, n-1).

  • Remove All adjacent Duplicates in String II
    October 23, 2019

    Given a string s, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them causing the left and the right side of the deleted substring to concatenate together.

  • Get Equal Substrings Within Budget
    October 23, 2019

    You are given two strings s and t of the same length. You want to change s to t. Changing the i-th character of s to i-th character of t costs |s[i] - t[i]| that is, the absolute difference between the ASCII values of the characters.

  • Unique number of Occurrences
    October 23, 2019

    Given an array of integers arr, write a function that returns true if and only if the number of occurrences of each value in the array is unique.

  • Sort Items by Groups Respecting Dependencies
    October 23, 2019

    There are n items each belonging to zero or one of m groups where group[i] is the group that the i-th item belongs to and it’s equal to -1 if the i-th item belongs to no group. The items and the groups are zero indexed. A group can have no item belonging to it.

  • Smallest String with Swaps
    October 23, 2019

    You are given a string s, and an array of pairs of indices in the string pairs where pairs[i] = [a, b] indicates 2 indices(0-indexed) of the string.

  • Ugly number III
    October 23, 2019

    Write a program to find the n-th ugly number.

  • Minimum Absolute Difference
    October 23, 2019

    Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.

  • Integer to Roman
    October 23, 2019

    Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.

  • Critical Connections in a Network
    October 23, 2019

    There are n servers numbered from 0 to n-1 connected by undirected server-to-server connections forming a network where connections[i] = [a, b] represents a connection between servers a and b. Any server can reach any other server directly or indirectly through the network.

  • K-Concatenation Maximum Sum
    October 23, 2019

    Given an integer array arr and an integer k, modify the array by repeating it k times.

  • Reverse Substrings Between Each Pair of Parentheses
    October 23, 2019

    You are given a string s that consists of lower case English letters and brackets.

  • Number of Valid Words for Each Puzzle
    October 23, 2019

    With respect to a given puzzlewordvalid

  • Can Make Palindrome from Substring
    October 23, 2019

    Given a string s, we make queries on substrings of s.

  • Diet Plan Performance
    October 23, 2019

    A dieter consumes calories[i] calories on the i-th day. For every consecutive sequence of k days, they look at T, the total calories consumed during that sequence of k days:

  • Prime Arrangements
    October 23, 2019

    Return the number of permutations of 1 to n so that prime numbers are at prime indices (1-indexed.)

  • Container With Most Water
    October 23, 2019

    Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.

  • Regular Expression Matching
    October 23, 2019

    Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'.

  • Two Sum
    October 23, 2019

    Given an array of integers, return indices of the two numbers such that they add up to a specific target.

  • A Latex Presentation/Poster Template for NYU
    May 08, 2019

    Recently, when I was working on my capstone paper for my undergraduate degree at NYUAD, I felt obliged to follow NYU’s visual guideline when making my presentations and posters. It turned out easier than I thought to adopt NYU’s color scheme. So I decided to make a template available to everyone at NYU. I have included styles for NYU, NYU Abu Dhabi and NYU Shanghai.

© 2022 Jin Shang. Powered by Jekyll using the So Simple Theme.