Skip to content

Instantly share code, notes, and snippets.

import Foundation
extension String {
func safeStr(i: Int) -> String {
guard i >= 0 && i < self.count else {
fatalError()
}
return String(self[self.index(self.startIndex, offsetBy: i)])
}
func safeChar(i: Int) -> Character {
import Foundation
extension String {
func safeStr(i: Int) -> String {
guard i >= 0 && i < self.count else {
class Solution {
func longestPalindrome(_ s: String) -> String {
var stepper = 0
if s.count == 1 { return String(s.first!) }
if s.count == 2 {
if s.last == s.first {
return s
func lengthOfLongestSubstring(_ s: String) -> Int {
var cache = [Character: Int]()
var tempMax = 0
var max = 0
var start = 0
for c in s.enumerated() {
// check if we've seen char before
class Settings: Equatable {
private var lastCommit: [SettingGroup] = initialSearchSettings()
init(initialSettings: [SettingGroup]) {
lastCommit = initialSettings
resetToLastCommit()
func getValue<T>(forId id: String) throws -> T {
for group in groups {
if let value = group.getValue(forId: id) {
switch value {
case .enumeration(let state):
if let result = state.current as? T {
return result
} else {
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
const path = require("path");
module.exports = {
entry: "./src/index.js",
output: {
path: __dirname + "/dist/",
filename: "bundle.js"
},
mode: "development",
module: {
{
"name": "test-SC",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack"
},
"keywords": [],
{
"name": "ab-chart",
"version": "1.0.0",
"description": "",
"main": "dist/bundle.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack"
},
"keywords": [],