Skip to content

Commit 383dcdd

Browse files
committed
Remove package & rename function name
1 parent a5104f4 commit 383dcdd

10 files changed

+10
-36
lines changed

kotlin/Two Pointers/IsPalindromeValid.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
package common.twopointers.ispalindrome
2-
31
class IsPalindromeValid {
42

5-
fun solution(s: String): Boolean {
3+
fun isPalindromeValid(s: String): Boolean {
64
var left = 0
75
var right = s.length - 1
86
while (left < right) {

kotlin/Two Pointers/LargestContainer.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
package common.twopointers.largestcontainer
2-
3-
import kotlin.math.max
4-
import kotlin.math.min
5-
61
class LargestContainer {
72

8-
fun solution(heights: List<Int>): Int {
3+
fun largestContainer(heights: List<Int>): Int {
94
var maxWater = 0
105
var left = 0
116
var right = heights.size - 1

kotlin/Two Pointers/LargestContainerBruteForce.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
package common.twopointers.largestcontainer
2-
3-
import kotlin.math.max
4-
import kotlin.math.min
5-
61
class LargestContainerBruteForce {
72

8-
fun solution(heights: List<Int>): Int {
3+
fun largestContainerBruteForce(heights: List<Int>): Int {
94
val n = heights.size
105
var maxWater = 0
116
// Find the maximum amount of water stored between all pairs of lines.

kotlin/Two Pointers/NextLexicographicalSequence.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
package common.twopointers.nextlexicographicalsequence
2-
31
class NextLexicographicalSequence {
42

5-
fun solution(s: String): String {
3+
fun nextLexicographicalSequence(s: String): String {
64
val letters = s.toCharArray()
75

86
// Locate the pivot, which is the first character from the right that breaks

kotlin/Two Pointers/PairSumSorted.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
package common.twopointers.pairsumsorted
2-
31
class PairSumSorted {
42

5-
fun solution(nums: IntArray, target: Int): List<Int> {
3+
fun pairSumSorted(nums: IntArray, target: Int): List<Int> {
64
var left = 0
75
var right = nums.size - 1
86
while (left < right) {

kotlin/Two Pointers/PairSumSortedBruteForce.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
package common.twopointers.pairsumsorted
2-
31
class PairSumSortedBruteForce {
42

5-
fun solution(nums: IntArray, target: Int): List<Int> {
3+
fun pairSumSortedBruteForce(nums: IntArray, target: Int): List<Int> {
64
val n = nums.size
75
for (i in 0 until n) {
86
for (j in i + 1 until nums.size) {

kotlin/Two Pointers/ShiftZeroToTheEnd.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
package common.twopointers.shiftzero
2-
31
class ShiftZeroToTheEnd {
42

5-
fun solution(nums: IntArray) {
3+
fun shiftZerosToTheEnd(nums: IntArray) {
64
// The 'left' pointer is used to position non-zero elements.
75
var left = 0
86
// Iterate through the array using a 'right' pointer to locate non-zero

kotlin/Two Pointers/ShiftZeroToTheEndNaive.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
package common.twopointers.shiftzero
2-
31
class ShiftZeroToTheEndNaive {
42

5-
fun solution(nums: IntArray) {
3+
fun shiftZerosToTheEndNaive(nums: IntArray) {
64
val temp = IntArray(nums.size)
75
var i = 0
86

kotlin/Two Pointers/TripletSum.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
package common.twopointers.tripletsum
2-
31
class TripletSum() {
42

5-
fun solution(nums: List<Int>): List<List<Int>> {
3+
fun tripletSum(nums: List<Int>): List<List<Int>> {
64
val triplets = mutableListOf<List<Int>>()
75
val sortedNums = nums.sorted()
86
for (i in sortedNums.indices) {

kotlin/Two Pointers/TripletSumBruteForce.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
package common.twopointers.tripletsum
2-
31
class TripletSumBruteForce {
42

5-
fun solution(nums: List<Int>): List<List<Int>> {
3+
fun tripletSumBruteForce(nums: List<Int>): List<List<Int>> {
64
// Use a hash set to ensure we don't add duplicate triplets.
75
val triplets = hashSetOf<List<Int>>()
86
// Iterate through the indexes of all triplets. O(n^3)

0 commit comments

Comments
 (0)