카타 8급 Enumerable Magic #3 - Does My List Include This?

1 C[ | ]

#include <stdbool.h>
#include <stddef.h>
bool include(const int* arr, size_t size, int item) {
  for(int i=0; i<size; i++) {
    if(arr[i] == item) return true;
  }
  return false;
}

2 Kotlin[ | ]

fun include(arr: IntArray, item : Int): Boolean {
    return arr.contains(item)
}
fun include(arr: IntArray, item: Int): Boolean = item in arr
fun include(arr: IntArray, item : Int): Boolean = arr.any { it == item }
fun include(arr: IntArray, item : Int): Boolean {
  return arr.indexOf(item) >= 0
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}