logo

Coding Interview Problems

DIFFICULTYPROBLEMONLINE JUDGESSOLUTIONS

Medium

3sum-closest

LeetCode 16
Java

Medium

3sum

LeetCode 15
Java

Medium

4sum

LeetCode 18
Java

Easy

add-binary

LeetCode 67
Java

Easy

add-digits

LeetCode 258
Java

Medium

add-two-numbers

LeetCode 258
Java

Medium

anagrams

LintCode 171
Java

Medium

backpack-ii

LintCode 125
Java

Medium

backpack

LintCode 92
Java

Easy

balanced-binary-tree

LeetCode 110
Java

balanced-lineup

POJ 3264
Java

Medium

best-time-to-buy-and-sell-stock-ii

LeetCode 122
Java

Medium

best-time-to-buy-and-sell-stock-iii

LeetCode 123
Java

Easy

best-time-to-buy-and-sell-stock

LeetCode 121
Java

Hard

binary-representation

LintCode 180
Java

Medium

binary-search-tree-iterator

LeetCode 173
Java

Easy

binary-tree-inorder-traversal

LeetCode 94
Java
Python

Medium

binary-tree-level-order-traversal-ii

LeetCode 107
Java

Medium

binary-tree-level-order-traversal

LeetCode 102
Java

Hard

binary-tree-maximum-path-sum

LeetCode 124
Java

Easy

binary-tree-path-sum

LintCode 1358
Java

Easy

binary-tree-paths

LeetCode 257
Java

Easy

binary-tree-postorder-traversal

LeetCode 145
Java
Python

Easy

binary-tree-preorder-traversal

LeetCode 144
Java
Python

Medium

binary-tree-zigzag-level-order-traversal

LeetCode 103
LintCode 71
Java

Hard

candy

LeetCode 135
Java

Easy

climbing-stairs

LeetCode 70
Java

Medium

clone-binary-tree

LintCode 375
Java

Medium

clone-graph

LeetCode 133
Java

Medium

coins-in-a-line

LintCode 394
Java

Medium

combination-sum-ii

LeetCode 377
LintCode 564
Java

Medium

combination-sum-iv

LeetCode 40
Java

Medium

combination-sum

LeetCode 39
Java

Medium

combinations

LintCode 152
Java

Easy

compare-strings

LintCode 55
Java

Medium

construct-binary-tree-from-inorder-and-postorder-traversal

LeetCode 106
Java

Medium

construct-binary-tree-from-preorder-and-inorder-traversal

LeetCode 105
Java

Medium

container-with-most-water

LeetCode 11
Java

Medium

continuous-subarray-sum

LeetCode 523
Java

Medium

convert-binary-search-tree-to-sorted-doubly-linked-list

LeetCode 426
LintCode 1534
Java

Easy

convert-sorted-array-to-binary-search-tree-with-minimal-height

LeetCode 108
Java

Medium

convert-sorted-list-to-balanced-bst

LeetCode 109
Java

Medium

copy-list-with-random-pointer

LeetCode 138
Java

Easy

cosine-similarity

LintCode 445
Java

Easy

count-1-in-binary

LintCode 365
Java

Easy

count-and-say

LeetCode 38
LintCode 420
Java

data-stream-median

Java

Medium

decode-ways

LeetCode 91
Java

Medium

delete-digits

LintCode 182
Java

Easy

delete-node-in-the-middle-of-singly-linked-list

LeetCode 237
LintCode 372
Java

Medium

design-add-and-search-words-data-structure

LeetCode 211
Java

Hard

distinct-subsequences

LeetCode 115
LintCode 118
Java

Hard

edit-distance

LeetCode 72
LintCode 119
Java

Medium

evaluate-reverse-polish-notation

LeetCode 150
LintCode 424
Java

Medium

fast-power

LintCode 140
Java

Easy

fibonacci

LintCode 366
Java

Hard

find-minimum-in-rotated-sorted-array-ii

LeetCode 154
LintCode 160
Java

Medium

find-minimum-in-rotated-sorted-array

LeetCode 153
LintCode 159
Java

Medium

find-peak-element

LeetCode 162
LintCode 75
Java

Medium

find-the-missing-number

LintCode 681
Java

Easy

first-bad-version

LeetCode 278
LintCode 74
Java

Hard

first-missing-positive

LeetCode 41
LintCode 189
Java
Go

Easy

first-position-of-target

LintCode 14
Java

Easy

fizz-buzz

LeetCode 412
LintCode 9
Java

Medium

flatten-binary-tree-to-linked-list

LeetCode 114
LintCode 453
Java

Easy

flatten-list

LintCode 22
Java

Easy

flip-bits

LintCode 181
Java

Medium

gas-station

LeetCode 134
LintCode 187
Java
Go

Medium

generate-parentheses

LeetCode 22
LintCode 427
Java

Medium

graph-valid-tree

LeetCode 261
LintCode 178
Java

Medium

gray-code

LeetCode 89
LintCode 411
Java

Easy

happy-number

LeetCode 202
LintCode 488
Java

Easy

hash-function

LintCode 128
Java

Medium

heapify

LintCode 130
Java

Medium

house-robber-ii

LeetCode 213
LintCode 534
Java

Medium

house-robber-iii

LeetCode 337
LintCode 535
Java

Medium

house-robber

LeetCode 198
LintCode 392
Java

Medium

implement-queue-by-two-stacks

LintCode 40
Java

Easy

implement-strstr

LeetCode 28
LintCode 13
Java

Medium

implement-trie-prefix-tree

LeetCode 208
LintCode 442
Java

Medium

insert-interval

LeetCode 57
LintCode 40
Java

Easy

insert-node-in-a-binary-search-tree

LintCode 85
Java

Medium

insertion-sort-list

LeetCode 147
LintCode 173
Java
Go

Medium

integer-to-roman

LeetCode 12
LintCode 418
Java

Medium

interleaving-positive-and-negative-numbers

LintCode 144
Java

Medium

interleaving-string

LeetCode 97
LintCode 29
Java

Easy

intersection-of-two-arrays-ii

LeetCode 350
LintCode 548
Java

Easy

intersection-of-two-arrays

LeetCode 349
LintCode 547
Java

Easy

intersection-of-two-linked-lists

LeetCode 160
LintCode 380
Java

Medium

interval-minimum-number

LintCode 205
Java

Medium

interval-sum

LintCode 206
Java

Easy

invert-binary-tree

LeetCode 226
LintCode 175
Java

Medium

jump-game-ii

LeetCode 45
LintCode 117
Java

Medium

jump-game

LeetCode 55
LintCode 116
Java

Medium

kth-largest-element

LintCode 5
Java

Medium

kth-smallest-number-in-sorted-matrix

LintCode 401
Java

Medium

largest-number

LeetCode 179
LintCode 184
Java

Easy

left-pad

LintCode 524
Java

Easy

length-of-last-word

LeetCode 58
LintCode 422
Java

Medium

letter-combinations-of-a-phone-number

LeetCode 17
LintCode 425
Java

Medium

linked-list-cycle-ii

LeetCode 142
LintCode 103
Java

Easy

linked-list-cycle

LeetCode 141
LintCode 102
Java

Medium

lonely-integer

HackerRank
Java

Easy

longest-common-prefix

LeetCode 14
LintCode 78
Java

Medium

longest-common-subsequence

LeetCode 1143
LintCode 77
Java

Medium

longest-common-substring

LintCode 79
Java

Medium

longest-consecutive-sequence

LeetCode 128
LintCode 124
Java

Easy

longest-increasing-continuous-subsequence

LintCode 397
Java

Medium

longest-increasing-subsequence

LeetCode 300
LintCode 76
Java

Medium

longest-palindromic-substring

LeetCode 5
LintCode 200
Java

Medium

longest-substring-without-repeating-characters

LeetCode 3
LintCode 384
Java

Easy

longest-words

LintCode 133
Java

Medium

lowest-common-ancestor-of-a-binary-tree

LeetCode 236
LintCode 88
Java

Hard

lru-cache

LeetCode 146
LintCode 134
Java

Easy

majority-number

LintCode 46
Java

Medium

majority-number-ii

LintCode 47
Java

Medium

majority-number-iii

LintCode 48
Java

Easy

matrix-zigzag-traversal

LintCode 185
Java

Hard

max-points-on-a-line

LeetCode 149
LintCode 186
Java

Easy

maximum-depth-of-binary-tree

LeetCode 104
LintCode 97
Java

Medium

maximum-product-subarray

LeetCode 152
LintCode 191s
Java

Medium

maximum-subarray-difference

LintCode 45
Java

Medium

maximum-subarray-ii

LintCode 42
Java

Easy

maximum-subarray

LintCode 41
Java

Easy

median

LintCode 80
Java

Medium

merge-intervals

LeetCode 56
LintCode 156
Java

Hard

merge-k-sorted-lists

LeetCode 23
LintCode 104
Java

Easy

merge-sorted-array

LeetCode 88
Java

Easy

merge-two-sorted-arrays

LintCode 6
Java
Go

Easy

merge-two-sorted-lists

LeetCode 21
LintCode 165
Java

Easy

min-stack

LeetCode 155
LintCode 12
Java

Medium

minimum-adjustment-cost

LintCode 91
Java

Easy

minimum-depth-of-binary-tree

LeetCode 111
LintCode 155
Java

Medium

minimum-path-sum

LeetCode 64
LintCode 110
Java

Medium

minimum-size-subarray-sum

LeetCode 209
LintCode 406
Java

Easy

minimum-subarray

LintCode 44
Java

Easy

mock-hanoi-tower-by-stacks

LintCode 227
Java

Easy

move-zeroes

LeetCode 283
LintCode 539
Java

Hard

n-queens-ii

LeetCode 52
LintCode 34
Java

Hard

n-queens

LeetCode 51
LintCode 33
Java

Medium

next-permutation

LeetCode 31
LintCode 52
Java

Easy

nth-to-last-node-in-list

LintCode 166
Java

Medium

number-of-airplanes-in-the-sky

LintCode 391
Java
Go

Medium

number-of-islands

LeetCode 200
LintCode 433
Java
Go

Medium

o1-check-power-of-2

LintCode 142
Java

Easy

paint-fence

LintCode 514
Java

Medium

paint-house

LintCode 515
Java

Easy

palindrome-linked-list

LeetCode 234
LintCode 223
Java

Medium

palindrome-partitioning

LeetCode 131
LintCode 136
Java

Easy

partition-array-by-odd-and-even

LintCode 373
Java

Medium

partition-array

LintCode 31
Java

Medium

partition-list

LeetCode 86
LintCode 96
Java

Hard

patching-array

LeetCode 330
LintCode 1290
C++

Medium

permutation-index

LintCode 197
Java

Hard

permutation-sequence

LeetCode 60
LintCode 388
Java

Medium

permutations-ii

LeetCode 47
LintCode 16
Java

Medium

permutations

LeetCode 46
LintCode 15
Java

Easy

plus-one

LeetCode 66
LintCode 407
Java

Medium

powx-n

LeetCode 50
LintCode 428
Java

Medium

previous-permutation

LintCode 51
Java

Medium

print-numbers-by-recursion

LintCode 371
Java

Easy

product-of-array-exclude-itself

LintCode 50
Java

Easy

recover-rotated-sorted-array

LintCode 39
Java

Medium

rehashing

LintCode 129
Java

Medium

remove-duplicates-from-sorted-array-ii

LeetCode 80
LintCode 101
Java

Easy

remove-duplicates-from-sorted-array

LeetCode 26
LintCode 100
Java

Medium

remove-duplicates-from-sorted-list-ii

LeetCode 82
LintCode 113
Java
Go

Easy

remove-duplicates-from-sorted-list

LeetCode 83
LintCode 112
Java
Go

Easy

remove-element

LeetCode 27
LintCode 172
Java

Easy

remove-linked-list-elements

LeetCode 203
LintCode 452
Java

Hard

remove-node-in-binary-search-tree

LintCode 87
Java

Medium

remove-nth-node-from-end-of-list

LeetCode 19
LintCode 174
Java

Medium

reorder-list

LeetCode 143
LintCode 99
Java

Medium

repeated-dna-sequences

LeetCode 187
LintCode 1335
Java

Medium

restore-ip-addresses

LeetCode 93
LintCode 426
Java

Medium

reverse-integer

LeetCode 7
LintCode 413
Java

Medium

reverse-linked-list-ii

LeetCode 92
LintCode 36
Java
Go

Easy

reverse-linked-list

LeetCode 206
LintCode 35
Java
Go

Hard

reverse-nodes-in-k-group

LeetCode 25
LintCode 450
Java

Hard

reverse-pairs

LeetCode 493
LintCode 532
Java

Medium

reverse-words-in-a-string

LeetCode 151
LintCode 53
Java

Easy

roman-to-integer

LeetCode 13
LintCode 419
Java

Medium

rotate-array

LeetCode 189
LintCode 1334
C++

Medium

rotate-image

LeetCode 48
LintCode 161
Java

Medium

rotate-list

LeetCode 61
LintCode 170
Java
Go

Easy

rotate-string

LeetCode 796
LintCode 8
Java

Medium

route-between-two-nodes-in-graph

LintCode 176
Java

Easy

same-tree

LeetCode 100
LintCode 469
Java

Medium

search-a-2d-matrix-ii

LeetCode 240
LintCode 38
Java

Medium

search-a-2d-matrix

LeetCode 74
LintCode 28
Java

Medium

search-for-a-range

LintCode 61
Java

Medium

search-in-rotated-sorted-array-ii

LeetCode 81
LintCode 63
Java

Medium

search-in-rotated-sorted-array

LeetCode 33
LintCode 62
Java
Python

Easy

search-insert-position

LeetCode 35
LintCode 60
Java

Medium

search-range-in-binary-search-tree

LintCode 11
Java

Medium

segment-tree-build-ii

LintCode 439
Java

Medium

segment-tree-build

LintCode 201
Java

Medium

segment-tree-modify

LintCode 203
Java

Medium

segment-tree-query-ii

LintCode 247
Java

Medium

segment-tree-query

LintCode 202
Java

serialize-and-deserialize-binary-tree

LeetCode 297
LintCode 7
Java

Medium

set-matrix-zeroes

LeetCode 73
LintCode 162
Java

Medium

shape-factory

LintCode 497
Java

Medium

shortest-unique-prefix

InterviewBit
C++

Medium

simplify-path

LeetCode 71
LintCode 421
Java
Go

Medium

single-number-ii

LeetCode 137
LintCode 83
Java

Medium

single-number-iii

LeetCode 260
LintCode 84
Java

Easy

single-number

LeetCode 136
LintCode 82
Java

Easy

singleton

LintCode 204
Java

Medium

sort-colors-ii

LintCode 143
Java

Medium

sort-colors

LeetCode 75
LintCode 148
Java

Easy

sort-integers-ii

LintCode 464
Java

Easy

sort-integers

LintCode 463
Java

Medium

sort-letters-by-case

LintCode 49
Java

Medium

sort-list

LeetCode 148
LintCode 98
Java
Go

Easy

space-replacement

LintCode 212
Java

Medium

spiral-matrix-ii

LeetCode 59
LintCode 381
Java

Medium

spiral-matrix

LeetCode 54
LintCode 374
Java

Easy

sqrtx

LeetCode 69
Java

Easy

string-permutation

LintCode 211
Java

Easy

subarray-sum

LintCode 138
Java

Medium

subsets-ii

LeetCode 90
LintCode 18
Java

Medium

subsets

LeetCode 78
LintCode 17
Java

Medium

subtree

LintCode 245
Java

Medium

sum-of-two-integers

LeetCode 371
Java

Medium

super-ugly-number

LeetCode 313
LintCode 518
Java

Medium

surrounded-regions

LeetCode 130
LintCode 477
Java

Medium

swap-nodes-in-pairs

LeetCode 24
LintCode 451
Java

Medium

swap-two-nodes-in-linked-list

LintCode 511
Java

Easy

symmetric-tree

LeetCode 101
LintCode 1360
Java

Hard

the-skyline-problem

LeetCode 218
LintCode 131
Python

Medium

the-smallest-difference

LintCode 387
Java

Medium

topological-sorting

LintCode 127
Java

Easy

toy-factory

LintCode 496
Java

Easy

trailing-zeros

LintCode 2
Java

Hard

trapping-rain-water

LeetCode 42
LintCode 363
Java

Medium

triangle

LeetCode 120
LintCode 109
Java

two-strings-are-anagrams

Java

Easy

two-sum

LeetCode 1
LintCode 56
Java

Medium

ugly-number-ii

LeetCode 264
LintCode 4
Java

Easy

ugly-number

LeetCode 263
LintCode 517
Java

Medium

unique-binary-search-trees-ii

LeetCode 95
LintCode 164
Java

Medium

unique-binary-search-trees

LeetCode 96
LintCode 163
Java

Easy

unique-characters

LintCode 157
Java

Medium

unique-paths-ii

LeetCode 63
LintCode 115
Java

Medium

unique-paths

LeetCode 62
LintCode 114
Java

Medium

update-bits

LintCode 179
Java

Easy

valid-palindrome

LeetCode 125
LintCode 415
Java

Easy

valid-parentheses

LeetCode 20
LintCode 423
Java

Medium

valid-sudoku

LeetCode 36
LintCode 389
Java

Medium

validate-binary-search-tree

LeetCode 98
LintCode 95
Java

Medium

wiggle-sort

LintCode 508
Java

Hard

wood-cut

LintCode 183
Java

Hard

word-break-ii

LeetCode 140
LintCode 582
Java

Medium

word-break

LeetCode 139
LintCode 107
Java

Medium

word-count-map-reduce

LintCode 499
Java

Hard

word-ladder-ii

LeetCode 126
LintCode 121
Java

Hard

word-ladder

LeetCode 127
LintCode 120
Java

Medium

word-search

LeetCode 79
LintCode 123
Java