[Link] https://leetcode.com/problems/reverse-nodes-in-k-group/ /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} ...
LeetCode. 24. Swap Nodes in Pairs
[Link] https://leetcode.com/problems/swap-nodes-in-pairs/ /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ...
LeetCode. 23. Merge k Sorted Lists
[Link] https://leetcode.com/problems/merge-k-sorted-lists/ Slow runtime…Can improve this by unsing priorityque. /** * Definition for singly-linked list. * public class ListNode { * int...
LeetCode. 21. Merge Two Sorted Lists
[Link] https://leetcode.com/problems/merge-two-sorted-lists/ /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ...
LeetCode. 10. Regular Expression Matching
[Link] https://leetcode.com/problems/regular-expression-matching/ class Solution { public boolean isMatch(String s, String p) { return test(s, p, 0, 0); } public boolean test(String...
LeetCode. 20. Valid Parentheses
[Link] https://leetcode.com/problems/valid-parentheses/ class Solution { public boolean isValid(String s) { Stack<Character> stack = new Stack<>(); for(int i = 0...
LeetCode. 17. Letter Combinations of a Phone Number
[Link] https://leetcode.com/problems/letter-combinations-of-a-phone-number/ class Solution { int len; public List<String> letterCombinations(String digits) { if(digits.len...
AtCoder. 021 Come Back in One Piece(5)
[Link] https://AtCoder.jp/contests/typical90/tasks/typical90_u Using class would make code lot more readable and easy to understand but I wanted to solved it fast since it’s late. import java.u...
Graph theory. Strongly Connected Component(SCC)
#Strongly Connected Component In directed graph, SCC means two components which are reachable in both ways #Algorithm (to get SCC) – Kosaraju’s algorithm(DFS) – Tarjan’s algorithm #Tarjan’s algor...
LeetCode. 19. Remove Nth Node From End of List
[Link] https://leetcode.com/problems/remove-nth-node-from-end-of-list/ /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode...