Instantly share code, notes, and snippets.

# bachiri Taoufiq Abderrahmanbachiri

• Sort options
Created Dec 7, 2019
Solution for StoneWall Codility
View StoneWallCodility.java
 package codility.stackandqueues; import java.util.Stack; //Codility Lesson 7 //Stacks and Queues //Problem :StoneWall //Link : https://app.codility.com/programmers/lessons/7-stacks_and_queues/ public class StoneWall { public static void main(String[] args) {
Created Sep 5, 2019
 import java.util.LinkedList; public class GraphAdjacencyListRepresentation { public static void main(String[] args) throws GraphRep.GraphException { GraphRep graphRep = new GraphRep(6); graphRep.addVertexTo(new GraphNode(4), new GraphNode(5)); graphRep.addVertexTo(new GraphNode(4), new GraphNode(1)); graphRep.addVertexTo(new GraphNode(4), new GraphNode(6));
Created Sep 1, 2019
239. Sliding Window Maximum/Leetcode
View SlidingWindowMaximum.java
 public class SlidingWindowMaximum { public static void main(String[] args) { int[] nums = {1, 3, -1, -3, 5, 3, 6, 7}; System.out.println("Maxs are " + Arrays.toString(maxSlidingWindow(nums, 3))); } public static int[] maxSlidingWindow(int[] nums, int k) { List result = new ArrayList<>(); for (int i = 0; i < nums.length; i++) {
Last active Aug 31, 2019
23. Merge k Sorted Lists /Leetcode
View MergekSortedLists.java
 public class MergekSortedLists { public static void main(String[] args) { ListNode listNode = new ListNode(1); listNode.next = new ListNode(4); listNode.next.next = new ListNode(5); ListNode secondListNode = new ListNode(1); secondListNode.next = new ListNode(3); secondListNode.next.next = new ListNode(4);
Created Aug 31, 2019
451. Sort Characters By Frequency / Leetcode
View SortCharactersByFrequency.java
 public class SortCharactersByFrequency { public static void main(String[] args) { System.out.println(frequencySort("Leetcode")); } public static String frequencySort(String s) { HashMap map = new HashMap<>(); for (int i = 0; i < s.length(); i++) { map.put(s.charAt(i), map.getOrDefault(s.charAt(i), 0) + 1); }
Created Aug 31, 2019
Length of the largest subarray with contiguous elements
View LengthLargestSubArray.java
 public class LengthLargestSubArray { public static void main(String[] args) { int arr[] = {1, 2, 3, 4, 5, 6, 10, 8, 7, 9}; System.out.println("Length of the largest subArray is " + lengthLargestSubArray(arr)); } private static int lengthLargestSubArray(int[] arr) { Arrays.sort(arr); int counter = 0; int maxCounter = 0;
You can’t perform that action at this time.