LeetCode - String Compression - Day15 (1/15/2020)

String Compression Question Given an array of characters, compress it in-place. The length after compression must always be smaller than or equal to the original array. Every element of the array should be a character (not int) of length 1…

LeetCode - Longest Palindromic Substring- Day15 (1/15/2020)

Longest Palindromic Substring Question Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Example …

LeetCode - Design Tic-Tac-Toe - Day15 (1/15/2020)

Design Tic-Tac-Toe Question 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 is placed on an empty block. Once a winning condition is rea…

LeetCode - LRU Cache - Day14 (1/14/2020)

LRU Cache Question Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the value (will always be positive) of the key if the key exists in the c…

LeetCode - Reverse Words in a String - Day12 (1/12/2020)

Reverse Words in a String Question Given an input string, reverse the string word by word. Example 1: Input: "the sky is blue" Output: "blue is sky the" Example 2: Input: " hello world! " Output: "world! hello" Explanation: Your reversed s…

LeetCode - Trapping Rain Water - Day12 (1/12/2020)

Trapping Rain Water Question Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. The above elevation map is represented by array [0,1,0,2,1,…

LeetCode - Valid Tic-Tac-Toe State - Day 12 (1/12/2020)

Valid Tic-Tac-Toe State Question A Tic-Tac-Toe board is given as a string array board. Return True if and only if it is possible to reach this board position during the course of a valid tic-tac-toe game. The board is a 3 x 3 array, and co…

LeetCode - Maximum Length of a Concatenated String with Unique Characters - Day 11 (1/11/2020)

Preface I have never seen the question using bit-manipulation to manage characters. This question is from the question list sorted by Microsoft Interview Question. Maximum Length of a Concatenated String with Unique Characters Question Giv…

LeetCode - Preface - Day9

Came back to Seattle Finally, I came back to Seattle. I was so sleepy because of the jetlag, but I need to go to classes. In addition, I received the email from Microsoft that I will move forward to a first-round interview for security eng…

LeetCode - Linked List Cycle II - Day5 (1/5/2020)

Linked List Cycle II Question Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in…

LeetCode - Linked List Cycle - Day5 (1/5/2020)

Linked List Cycle Question Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If…

LeetCode - Merge two sorted lists - Day5 (1/5/2020)

Merge two sorted lists Question 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. Example: Input: 1->2->4, 1->3->4 Output: 1->1->2->3->4->4 Solutio…

LeetCode - Remove Nth Node From End of List - Day5 (1/5/2020)

Remove Nth Node From End of List Question Given a linked list, remove the n-th node from the end of list and return its head. Example: Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked lis…

LeetCode - Flatten a Multilevel Doubly Linked List - Day5 (1/5/2020)

Flatten a Multilevel Doubly Linked List Question You are given a doubly linked list which in addition to the next and previous pointers, it could have a child pointer, which may or may not point to a separate doubly linked list. These chil…

LeetCode - Preface - Day5 (1/5/2020)

Sunday I solved AtCoder questions (especially cumulative sum question) instead of LeetCode's question as LeetCode365 Day4 (It is not LeetCode365 challenge anymore?), but I believe to keep solving every day is important. Today I tackled the…

LeetCode - Preface - Day4 (1/4/2020)

Let's get started I have a headache... I might solve 2 or 3 questions today and will solve 7 questions tmr.

LeetCode - Bulls and Cows - Day3 (1/3/2020)

Bulls and Cows Question You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that indicates how…

LeetCode - Lisence Key Formatting - Day3 (1/3/2020)

Lisence Key Formatting Question You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string is separated into N+1 groups by N dashes. Given a number K, we would want to reformat t…

LeetCode - Backspace String Compare - Day3 (1/3/2020)

Backspace String Compare Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. Example 1: Input: S = "ab#c", T = "ad#c" Output: true Explanation: Both S and T become…

LeetCode - Compare Strings by Frequency of the Smallest Character - Day3 (1/3/2020)

Compare Strings by Frequency of the Smallest Character Question Let's define a function f(s) over a non-empty string s, which calculates the frequency of the smallest character in s. For example, if s = "dcce" then f(s) = 2 because the sma…

LeetCode - Logger Rate Limiter - Day3 (1/3/2020)

Logger Rate Limiter Question Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is not printed in the last 10 seconds. Given a message and a timestamp (in seco…

LeetCode - Preface - Day3 (1/3/2020)

寝正月? I spend most of the day to do Contrail CTF, so I picked 5 easy questions from Google.

LeetCode - Best Time to Buy and Sell Stock - Day2 (1/2/2020)

Best Time to Buy and Sell Stock Question 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 (i.e., buy one and sell one share of the stock)…

LeetCode - House Robber - Day2 (1/2/2020)

House Robber Question You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security s…

LeetCode - Maximum Subarray - Day2 (1/2/2020)

Maximum Subarray Question Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,-1,2,1] h…

LeetCode - Find k Pairs with Smallest Sums - Day2 (1/2/2020)

Find k Pairs with Smallest Sums Question You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element from the first array and one element from the second ar…

LeetCode - Subarray Sum Equals K - Day2 (1/2/2020)

Subarray Sum Equals K Question Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals k. Example 1: Input:nums = [1,1,1], k = 2 Output: 2 Note: The length of the array is in …

LeetCode - Preface - Day2

Let's get started I read Shiroyama-san's blog post today and figured out it describes exactly what I think about the programming recently. Since I used to major in business and recently switched my major to computer science, I always feel …

LeetCode - Is Subsequence - Day1 (1/1/2020)

Is Subsequence Question Given a string s and a string t, check if s is subsequence of t. You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string, and s is a shor…

LeetCode - Meeting Rooms II - Day1 (1/1/2020)

Meeting Rooms II Question Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of conference rooms required. Example 1: Input: [[0, 30],[5, 10],[15, 20]] Output…