Skip to content

Instantly share code, notes, and snippets.

/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
class Solution {
public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
public class LongestPalindrome {
public String longestPalindrome(String s) {
int length = s.length() - 1;
if(length <= 0) return s;
char[] input = s.toCharArray();
class Solution {
public int[] searchRange(int[] nums, int target) {
int[] result = new int[]{-1,-1};
if(nums.length == 0 || nums[0] > target) return result;
int start = 0, end = nums.length-1, midPoint = 0;
boolean found = false;
while(start<=end && !found){
midPoint = Math.round((start + end) / 2);
class Solution {
public List<List<Integer>> permute(int[] nums) {
List<List<Integer>> result = new ArrayList<>();
if(nums == null || nums.length == 0) return result;
List<Integer> listNums = new ArrayList<>(nums.length);
for (int i : nums) { listNums.add(i); }
permute(listNums, 0, nums.length, result);