SKSimon Kuanginsimonpyjavaplus.hashnode.dev·Oct 28, 2022 · 1 min readReorder listInput: head = [1,2,3,4] Output: [1,4,2,3] First find the middle of the list Second reverse the second half Third merge the two lists Find the middle of the list by using the fast pointer/slow pointer technique. //given ListNode head ListNode fast =...00
SKSimon Kuanginsimonpyjavaplus.hashnode.dev·Oct 27, 2022 · 1 min readReverse Linked ListThe trick to this problem... you need a runner node, a previous node, and nextTemp node. First initialize your prev node and runner node. //given ListNode head , reverse the linked list ListNode prev = null; ListNode run = head; Now we want to itera...00
SKSimon Kuanginsimonpyjavaplus.hashnode.dev·Oct 27, 2022 · 2 min readProducts of array except selfGiven an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. With this kind of question. You will need a pre-fixed array and a post fixed array. Left array containing all...00
SKSimon Kuanginsimonpyjavaplus.hashnode.dev·Oct 27, 2022 · 2 min readTop k frequent elementsGiven an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. When dealing with top k, we would like to think about a priority queue. But first we need to figure out how to keep track of a...00
SKSimon Kuanginsimonpyjavaplus.hashnode.dev·Oct 26, 2022 · 1 min readN-tier architectureThis is one of the first architectures I've learned when using spring The first layer is the front end framework. This layer can be any framework that is desired. I personally use angular, since it is the framework I code the most in. The next layer...00